Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - list all usesr in Domain Admins group

Reply
 
Old 12-02-2008   #1 (permalink)
R Shah


 
 

list all usesr in Domain Admins group

Hi All,

I am trying to get all members of Domain Admins group. But my script is only
showing me members who has UPN set. If the UPN is blank it does not show me
the members.

Would you please check it and help me to fix the code.

Dim strFilename

strFilePath = "C:\Documents and
Settings\ampaty.ravi\Desktop\Scripts\domaimembers.xlsx"

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True

Set objWorkbook = objExcel.Workbooks.Add()
objworkbook.SaveAs(strFilepath)
'objExcel.Workbooks.Add
intRow = 2

objExcel.Cells(1, 1).Value = "Account NAME"
objExcel.Cells(1, 2).Value = "Display Name"


strGroupDN = "cn=Domain Admins,cn=Users,dc=eom,dc=dcgov,dc=priv"

Set objFSO=CreateObject("Scripting.FileSystemObject")

'MODIFY THE PATH HERE TO SAVE THE REPORT

set objGroup = GetObject("LDAP://" & strGroupDN)
Wscript.Echo "Script Started!"

for each objMember in objGroup.Members
objExcel.Cells(intRow, 1).Value = objMember.SAMAccountName
objExcel.Cells(intRow, 2).Value = objMember.DisplayName
intRow = intRow + 1
next

Wscript.Echo "End of script."


Regards
Shah



My System SpecsSystem Spec
Old 12-02-2008   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: list all usesr in Domain Admins group


"R Shah" <raisboss@xxxxxx> wrote in message
news:OT9hH9JVJHA.2084@xxxxxx
Quote:

> Hi All,
>
> I am trying to get all members of Domain Admins group. But my script is
> only showing me members who has UPN set. If the UPN is blank it does not
> show me the members.
>
> Would you please check it and help me to fix the code.
>
> Dim strFilename
>
> strFilePath = "C:\Documents and
> Settings\ampaty.ravi\Desktop\Scripts\domaimembers.xlsx"
>
> Set objExcel = CreateObject("Excel.Application")
> objExcel.Visible = True
>
> Set objWorkbook = objExcel.Workbooks.Add()
> objworkbook.SaveAs(strFilepath)
> 'objExcel.Workbooks.Add
> intRow = 2
>
> objExcel.Cells(1, 1).Value = "Account NAME"
> objExcel.Cells(1, 2).Value = "Display Name"
>
>
> strGroupDN = "cn=Domain Admins,cn=Users,dc=eom,dc=dcgov,dc=priv"
>
> Set objFSO=CreateObject("Scripting.FileSystemObject")
>
> 'MODIFY THE PATH HERE TO SAVE THE REPORT
>
> set objGroup = GetObject("LDAP://" & strGroupDN)
> Wscript.Echo "Script Started!"
>
> for each objMember in objGroup.Members
> objExcel.Cells(intRow, 1).Value = objMember.SAMAccountName
> objExcel.Cells(intRow, 2).Value = objMember.DisplayName
> intRow = intRow + 1
> next
>
> Wscript.Echo "End of script."
>
>
> Regards
> Shah
>
Your code should reveal all direct members of the group, except any members
that have the group designated as their "primary" group. The Members method
of the group object never reveals any object that has the group designated
as their "Primary" group. Having a value assigned to the userPrincipalName
attribute should not be a factor.

If for some reason you have designated "Domain Admins" as the "primary"
group (not recommended), I have an example VBScript program that documents
all members of any domain group, including membership due to group nesting
and the "primary" group, linked here:

http://www.rlmueller.net/List%20Memb...0a%20Group.htm

To retrieve all objects that have a specific group designated as their
"primary", bind to the group object and retrieve the value of the
"primaryGroupToken" attribute. This attribute is operational (also called
constructed), so you must use the GetInfoEx method to force AD to return the
value. All objects whose "primaryGroupID" attribute matches this value have
the group designated as their "primary". The program linked above use ADO to
query AD for all such objects (users or computers). If you are not
interested in membership due to group nesting, you can comment out the
recursive call in Sub EnumGroup, which is the statement:

Call EnumGroup(objMember, strOffset & " ")

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
add a global group to a domain local group VB Script
Difference between a domain group and a local group VB Script
Full Local Access for Domain Admins Network & Sharing
Add domain group to local group question VB Script
2 Domain Admins, 1 Gets Admin Rights, 1 Doesn't Vista account administration


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46