viewpoint-particle

Author Topic: How to Determine Whether Group or User?  (Read 2425 times)

keslaa

  • Newbie
  • *
  • Posts: 37
How to Determine Whether Group or User?
« on: May 12, 2015, 05:47:43 am »
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

  • Tech Support
  • *****
  • Posts: 2154
    • WinBatch
Re: How to Determine Whether Group or User?
« Reply #1 on: May 12, 2015, 06:40:11 am »
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
strClass = dsGetProperty(strAdsiPath,"objectClass")
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


keslaa

  • Newbie
  • *
  • Posts: 37
Re: How to Determine Whether Group or User?
« Reply #2 on: May 12, 2015, 10:54:59 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
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

  • Tech Support
  • *****
  • Posts: 2154
    • WinBatch
Re: How to Determine Whether Group or User?
« Reply #3 on: May 12, 2015, 12:55:06 pm »
You can use the extender's 'dsGetPropName' function to get a list of the property names associated with an object. 

"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


keslaa

  • Newbie
  • *
  • Posts: 37
Re: How to Determine Whether Group or User?
« Reply #4 on: May 13, 2015, 04:30:47 am »
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

  • Tech Support
  • *****
  • Posts: 2154
    • WinBatch
Re: How to Determine Whether Group or User?
« Reply #5 on: May 13, 2015, 09:57:49 am »
My wife 'hides' objects from me by putting them on a shelf at eye level...
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


kdmoyers

  • Full Member
  • ***
  • Posts: 179
Re: How to Determine Whether Group or User?
« Reply #6 on: May 18, 2015, 08:23:35 am »
I hide things from myself using the same method!
-K
The mind is everything; What you think, you become.