WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADSI
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

List Groups Computer is Member Of

 Keywords:  

Question:

Can someone help me with a code snippit to show what AD groups a computer is a member of?

Answer:

Take a look at dsGetUsersGrps() in the ADSI extender. Computer objects and User objects both inherit from a common base class in the AD schema, so getting the group memberships for a computer account should be handled in the same way as getting group memberships for user accounts.

If you look at the example under the dsGetUsersGrps function's documentation in the help file you will notice the line

UserPath = dsFindPath(ServerPath, "(&(objectCategory=Person)(sAMAccountName=%SamName%))")
Simply change "Person" in the search filter to "Computer" to get a computer's full ADSI moniker for the call to dsGetUsersGrps. And as another poster mentioned a computer's samAccountName is usually the computer name + the '$' character appened to the end.
Article ID:   W16806
File Created: 2007:07:03:14:26:20
Last Updated: 2007:07:03:14:26:20