Question : Find User's OUs in Active Directory

I am trying to enumerate through the OUs a user is in. I can get the AdsPath (LDAP://CN=TestUser\, OU=Admin, OU=CompanyName, DC=testco, DC=org) for the user but I do not want to parse the path just to get the OUs (Admin, CompanyName). I will be using a Vbscript via WSH. I will be using the OUs as a criteria for code (ie. OU=Admin for the user will get a password never expires setting).

I heard from a Microsoft rep you cannot do this but I am sure someone has figured it out!

Answer : Find User's OUs in Active Directory

If you are going to be checking for certain OU's within the code itself, you could do something like this--

If InStr(1, AdsPath, "OU=Admin", 1) > 0 Then
   'code for admin stuff
End If
If InStr(1, AdsPath, "OU=OTHEROU", 1) > 0 Then
   'code for other OU
End If
'etc etc

That's one way to do it...
If you truly want a list of the OU's a user is in, what's wrong with parsing AdsPath for them? (Just wondering, might help me to understand the problem a bit better)

Cheers
Random Solutions  
 
programming4us programming4us