Link to home
Start Free TrialLog in
Avatar of lanter007
lanter007

asked on

VB Filter AD: How find one Person in ActiveDirectory OU Tree?

I have a code which allways worked until I tried to query another firms ActiveDirectory.

I also tried with this search filter:
"(&(objectCategory=person)(objectClass=user)(sn=" & searchstring & "))"
and within LDAP://xx.xxxx.xxx/CN=Users,DC=xx,DC=xxxx,DC=xxx,OU=OU2 London"


I could find Computers and disabled Accounts. But I can not get to User Data in Organization Units.

The Tree is as follows:
xx.xxxx.xxx
  OU1 Hong Kong  (Organization Unit)
  OU2 London  (Organization Unit)
  OU3 New York  (Organization Unit)
         Users (Organization Unit)
         Groups (Organization Unit)
etc...

Any Ideas? I tried for hours......and it is soooo important.
Thanks in advance.
Dim sPath As String = "LDAP://xx.xxxx.xxx/CN=Users,DC=xx,DC=xxxx,DC=xxx"
Dim adsRoot As New DirectoryServices.DirectoryEntry(sPath) 
Dim mySearcher As DirectoryServices.DirectorySearcher = New DirectoryServices.DirectorySearcher(adsRoot)
Dim searchstring As String = Request("id")
 
Try
 
mySearcher.PropertiesToLoad.AddRange(New String() {"sAMAccountName,sn, description", "displayName, givenName"})
mySearcher.Filter = "(sAMAccountName=xxxxxxx)"  
Dim myResult As DirectoryServices.SearchResult
myResult = mySearcher.FindOne
 
 
etc.....

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of raja_ind82
raja_ind82
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial