Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Group vs User Object class question

1,831 views
Skip to first unread message

Frank@discussions.microsoft.com David Frank

unread,
Apr 18, 2008, 2:28:02 PM4/18/08
to
I am looking for a way to determine if an object is a group or a user in
active directory. Here is a sample script that will sort out local users,
but for the non local users how can I determin

strComputer = "atl-fs-01"
strTestString = "/" & strComputer & "/"

Set colGroups = GetObject("WinNT://" & strComputer & "/Administrators")

For Each objUser In colGroups.Members
If InStr(objUser.AdsPath, strTestString) Then
Wscript.Echo "Local user: " & objUser.Name

ElseIf
objuser.name and objuser.class = User Then
Wscript.echo “I am a user”
Else
Wscript.Echo "I am a group " & objUser.Name
End If
End If
Next

Richard Mueller [MVP]

unread,
Apr 18, 2008, 8:08:05 PM4/18/08
to
David Frank wrote:

The Class property method of the member object reveals whether the member is
a group, computer, or user. This is true for the WinNT and LDAP providers.
All local and AD objects have a Class method. This is not the same as the
objectClass attribute of AD objects, which is multi-valued.

For group objects:
The objectClass attribute has the values: top, group
The Class property method returns "group"

For user objects:
The objectClass attribute has the values: top, person,
organizationalPerson, user
The Class property method returns "user"

For computer objects:
The objectClass attribute has the values: top, person,
organizationalPerson, user, computer
The Class property method returns "computer"

For Active Directory users:
======
Set objUser = GetObject("LDAP://cn=Jim Smith,ou=Sales,dc=MyDomain,dc=com")
Wscript.Echo "Class: " & objUser.Class

Set objUser = GetObject("WinNT://MyDomian/JSmith,user")
Wscript.Echo "Class: " & objUser.Class
======
In both cases, using LDAP or WinNT, the class is "user" (or "User").

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--


0 new messages