Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listing AD Computer Group Membership - Part II

Status
Not open for further replies.

Southpark

Technical User
Jul 20, 2003
11
GB
Hi Everyone

{Reposting as original thread is now corrupt for some reason)

I am rewriting a clients login script, and am trying to tackle the fact that there is a lot of computer and a lot of printers been mapped dependant on the computers whereabouts. Currently the login script is going through a painful process of using an IsMember function for every group that exists. i.e.

Is computer a member of the group GG-MBH-SECOND-NORTH
if so
map printer 1
map printer 2 (etc etc)
end if

Is computer a member of the group GG-MBH-THIRD-NORTH, well you get the gist

The problem is there is five floors in the building with four wings in each and as you can imagine the process is slow, and if a printer is replaced or a new one added, someone has to amend the login script - *GULP*

I have already externalised all the printer names into a CSV file, and have currently read this file in, (bear with me I'm getting to the root of the problem and to my question) what I am now trying to do is read into an array, for the current computer name, all the groups that the computer is a member of

I can then search the array for a group that starts with "GG-MBH" (there will only ever be one) and then search the printer file array and map all printers accordingly

Can anyone please help ??
 
This will give you Group Name, CN, and Domain Name of the current user.

Set wshNetwork = CreateObject("WScript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" &ADSysInfo.UserName)
For Each varRecord In currentUser.Memberof
msgbox varRecord
Next

You can compare you CSV file to each group return and set your if statments inside the for statment.

Hope this is what you were looking for.
 
greg0303

Many thanks for the reply, but what I am after is the exact same kind of loop but returning the group membership of the cuurent computer *not the user* :)

Hope your script can be amended to suit

Cheers
 
Switch ADSysinfo.UserName to ADSysinfo.Computername and that should give you the computer memberships for the domain.
 
Greg0303

Again many thanks for your reply, however when I follow your advice to change ADSysinfo.UserName to ADSysinfo.Computername the script errors with "Object is not a collection". Have you any further advice or ideas ??

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top