How to Determine Whether Group or User?

Started by keslaa, May 12, 2015, 05:47:43 AM

Previous topic - Next topic

keslaa

I am trying to untangle or AD groups. My though was to use WinBatch to go through a group, read each member and if it is a user/computer account, record to a text file. If the member is a nested group, open that up and read through the members, performing the same function - write the user/computer account to a file or traverse the nested group.

I can get most of this but I am having trouble getting WinBatch to tell me whether an object is a user, a computer or a group. Basically, how do I query the object class?

td

If you are interested in getting the the groups, nested groups and primary group for each user you can simply use the ADSI extender's dsGetUsersGrps function. You can find out more about the function in the Consolidated WIL Help file, if you have installed the extender.

To directly answer your question.  Once you have the full LDAP path to an object you can use the dsGetProperty to obtain its object class:

Code (winbatch) Select
strClass = dsGetProperty(strAdsiPath,"objectClass")
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

keslaa

Quote from: td on May 12, 2015, 06:40:11 AM

To directly answer your question.  Once you have the full LDAP path to an object you can use the dsGetProperty to obtain its object class:

Code (winbatch) Select
strClass = dsGetProperty(strAdsiPath,"objectClass")

That was it. Thank you! I was using "object class" instead of "objectclass".

Where can I get a list of these property names so I get the syntax correct going forward?

td

You can use the extender's 'dsGetPropName' function to get a list of the property names associated with an object. 

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

keslaa

Unbelievable. That's exactly what I was looking for but didn't see it until you told me. I don't know if it's age or exhaustion...

Thank you!

td

My wife 'hides' objects from me by putting them on a shelf at eye level...
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

kdmoyers

I hide things from myself using the same method!
-K
The mind is everything; What you think, you become.