Re: Missing Users in "Group Listing"...



William Robertson wrote:

> I have a very simple script which accepts the name of a User Group, and
then
> lists the names of all users who are a member thereof... An excerpt of
this
> script is listed below...
> '******************************************************
> ADGroup="CN=DialupUsers, OU=Servers"
> ADDomain="DC=domainname,DC=com"
>
> Set objGroup = GetObject ("LDAP://"&ADGroup&","&ADDomain)
> For each objMember in objGroup.Members
> WScript.Echo objMember.sAMAccountName & "," & objMember.sAMAccountName
&
> "," & objMember.Name
> Next
> '******************************************************
>
> The problem that I have is that any User Account that has the ADGroup in
> question as it's Primary Group, does not get included in my report. Case
in
> point:
> I have a few "contractor" logons of people who dialup into our
organisation
> for support purposes. These user accounts typically are not members of any
> Active Directory groups, apart from my "DialupUsers" group which is used
to
> authorise these support users on my IAS server. These user accounts are
only
> a member of 1 group, thus the "DialupUsers" group is set as the "Primary
> Group" for these users.
> I have managed to duplicate this as follows:
> - Set the Primary Group of a user account to "Group1"
> - Run the above script, and the user account in question will not be
> reported in the results
> - Take the same user account above, add them to another group, set the
> Primary group to this "Group2", and run the above script again.
> - The user i question will now be returned...
>
> Anyone perhaps got an idea on how to get past this??

Hi,

As you've discovered, the LDAP provider does not reveal membership in the
"primary" group, at least without extra effort. To find all users that have
a given group designated as their "primary", retrieve the value of the
"primaryGroupToken" attribute of the group object. Then, use ADO to search
for all users that have a matching value for the "primaryGroupID" attribute
of the user object. I have an example VBScript program that documents group
membership and demonstrates this linked here:

http://www.rlmueller.net/List%20Members%20of%20a%20Group.htm

The program above also reveals nested group membership, which your snippet
does not. If you don't have nested groups, another solution is to use the
WinNT provider. The WinNT provider is blind to nested groups, but the WinNT
Members method of the group object does include any members that have the
group designated as primary. Your snippet could be converted to use the
WinNT provider.

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


.



Relevant Pages

  • Re: Listing users from "Domain Users" group using AD query
    ... I want to know how to script listing of users in the "Domain Users" ... I've tried binding to the object and asking for the "members" entry ... but in the 'primaryGroupID' attribute on the user ...
    (microsoft.public.windows.server.scripting)
  • Re: list all usesr in Domain Admins group
    ... I am trying to get all members of Domain Admins group. ... only showing me members who has UPN set. ... Wscript.Echo "Script Started!" ... All objects whose "primaryGroupID" attribute matches this value have ...
    (microsoft.public.scripting.vbscript)
  • Re: List Members of a Group (with user input)
    ... Wscript.Echo "No members" ... Dim objRootDSE, objTrans, strNetBIOSDomain, strGroup ... I would like one that does not require editing of the script each time. ... Dim UserCount, gga, CNgga ...
    (microsoft.public.scripting.vbscript)
  • Re: I need help with a login script
    ... You rewrite the script but I think it will be time consuming trying ... "Costas" wrote: ... Users are members of security group Accounting sales etc. Lsnsrv01 is ... wshNetWork.SetDefaultPrinter "\\lsnsrv01\2840Color" ElseIf ...
    (microsoft.public.windows.server.sbs)
  • Re: I need help with a login script
    ... You rewrite the script but I think it will be time consuming trying ... On Error GoTo 0 ... Users are members of security group Accounting sales etc. Lsnsrv01 is the ... wshNetWork.SetDefaultPrinter "\\lsnsrv01\2840Color" ElseIf InStrThen ...
    (microsoft.public.windows.server.sbs)