G
Guest
Hi can someone please tell me how I change this directory service query so
that it searches through each record in the active directory and returns all
the accounts!
At the moment I can only get the query to return one account at a time!
I presume I have to create some kind of loop on the following so I return
all the users SAM info????
Dim SamAccount As String = Right(inSAM, Len(inSAM) - InStr(inSAM, "\"))
I would be really grateful for any help!
Thanks
<code>
Public Function GetUserInfo(ByVal inSAM As String, ByVal inType As String)
As String
Try
Dim sPath As String = "LDAP://netdomain.domain.com"
Dim SamAccount As String = Right(inSAM, Len(inSAM) -
InStr(inSAM, "\"))
'pass the user account and password for your Admin Account.
Dim myDirectory As New DirectoryEntry(sPath, "administrator",
"password")
Dim mySearcher As New DirectorySearcher(myDirectory)
Dim mySearchResultColl As SearchResultCollection
Dim mySearchResult As SearchResult
Dim myResultPropColl As ResultPropertyCollection
Dim myResultPropValueColl As ResultPropertyValueCollection
'Build LDAP query
mySearcher.Filter = ("(&(objectClass=user)(samaccountname=" &
SamAccount & "))")
mySearchResultColl = mySearcher.FindAll()
</code>
that it searches through each record in the active directory and returns all
the accounts!
At the moment I can only get the query to return one account at a time!
I presume I have to create some kind of loop on the following so I return
all the users SAM info????
Dim SamAccount As String = Right(inSAM, Len(inSAM) - InStr(inSAM, "\"))
I would be really grateful for any help!
Thanks
<code>
Public Function GetUserInfo(ByVal inSAM As String, ByVal inType As String)
As String
Try
Dim sPath As String = "LDAP://netdomain.domain.com"
Dim SamAccount As String = Right(inSAM, Len(inSAM) -
InStr(inSAM, "\"))
'pass the user account and password for your Admin Account.
Dim myDirectory As New DirectoryEntry(sPath, "administrator",
"password")
Dim mySearcher As New DirectorySearcher(myDirectory)
Dim mySearchResultColl As SearchResultCollection
Dim mySearchResult As SearchResult
Dim myResultPropColl As ResultPropertyCollection
Dim myResultPropValueColl As ResultPropertyValueCollection
'Build LDAP query
mySearcher.Filter = ("(&(objectClass=user)(samaccountname=" &
SamAccount & "))")
mySearchResultColl = mySearcher.FindAll()
</code>