I have a project that used the ActiveDS COM object. I am now rewriting it using the DirectoryServerices namespace within .Net
My ActiveDS code
worked fine. I inserted the full name of the user into an arraylist (emails).
with DirectoryServices
I get a null instance error when adding the names to the arraylist.
if I put the
in a try/catch statement the arraylist is populated, but the name for the null instance is displayed as
in the array list.
Anybody know why it's inserting this value if it was a null instance? Why is it being added if the try/catch statement looks like this:
Shouldn't it do nothing?
Jason Meckley
Database Analyst
WITF
Code:
Dim ADGrp As IADsGroup
Dim ADUsr As IADsUser
Dim DirEntry As New DirectoryEntry("LDAP://...")
Dim DirSearch As New DirectorySearcher(DirEntry)
Dim UserSearch As New DirectorySearcher(DirEntry)
Dim Result, UResult As SearchResult
Dim X As Integer
Dim Emails As New ArrayList()
Code:
ADGrp = GetObject("LDAP://...")
For Each ADUsr In ADGrp.Members
If ADUsr.AccountDisabled = False Then
Emails.Add(ADUsr.FullName)
End If
Next
with DirectoryServices
Code:
DirSearch.Filter = ("(CN=All Staff)")
DirSearch.PropertiesToLoad.Add("member")
Result = DirSearch.FindOne
For X = 0 To Result.Properties("member").Count - 1
UserSearch.Filter = ("(" & Left(Result.Properties("member").Item(X), InStr(Result.Properties("member").Item(X), ",") - 1) & ")")
UserSearch.PropertiesToLoad.Add("DisplayName")
UResult = UserSearch.FindOne()
Emails.Add(UResult.Properties("DisplayName").Item(0))
Next X
if I put the
Code:
emails.add(...)
Code:
AFFREL01$
Anybody know why it's inserting this value if it was a null instance? Why is it being added if the try/catch statement looks like this:
Code:
Try
Emails.Add(Emails.Add(UResult.Properties("DisplayName").Item(0))
Catch
End Try
Jason Meckley
Database Analyst
WITF