MIM 2016: VB.net Convert string to integer and Custom filter

Okay, its VB…Urgh…Not my cup of tea, love C# but for today, let me indulge in this semi-sweet delight.

Here is what I want to do

  1. I have an HR feed, the key is the employeeid field, its a string value.
  2. I want to be able to filter a range of employeeids, say 500-600.

To do a range filter I need integer values else I can’t user “<” or “>” unless they are integer

Solution

'First catch the person object and redirect to a function
Public Function FilterForDisconnection( _
ByVal csentry As CSEntry) _
As Boolean Implements IMASynchronization.FilterForDisconnection
If csentry.objecttype = "person" Then
return ProcessFilterPerson(csentry)
End If
End Function
Private Function ProcessFilterPerson( _
ByVal csentry As CSEntry) _
As Boolean
'Convert to integer
myemployeeid = Convert.ToInt32(csentry("employeeID").Value)
'Specify the one-offs
If myemployeeid = 11234 _
Or myemployeeid = 11237 _
Or myemployeeid = 22345 _
Or myemployeeid = 67899 _
Then
Return False
End If
'Specify the range
If myemployeeid < 40000 _ Or myemployeeid > 40630 Then
Return True
End If
Return False
End Function

Advertisements