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 John Tel 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 1

Status
Not open for further replies.

Southpark

Technical User
Jul 20, 2003
11
GB
Hi Everyone,

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

I cannot seem to work out how to retrieve all of the groups that the computer is currently a member of ??

Can anyone help please
 
Mark,

Many thanks for pointing me to your FAQ's, however, and unless Im not reading the page correctly, none of your example scripts loop through a computers group membership which is what I require

Thanks anyway, appreciate the response

Can anyone help me please ?

Cheers
 
As stated above I give an example of how to loop through a USERS group memberships. Bind to the computer object instead of the user object and you can use the same logic.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Mark,

I attempt to use the same logic for looping through the computer group membership, but I am now receiving the error message "Object not a collection"

Have you any further ideas or suggestions to help please ?

Cheers
 
this is how i do it


'go off and check for computer group membership
Dim objTrans, strComputerDN, objComputer, colGroups, strGroup, v
Set objTrans = CreateObject("NameTranslate")

objTrans.Set 3, "DOMFSC01\" & waspMach.ComputerName & "$"
strComputerDN = objTrans.Get(1)

Set objComputer = GetObject("LDAP://" & strComputerDN)
colGroups = objComputer.MemberOf

If IsEmpty(colGroups) Then
'machine is not a member of any other group than its primary group, ie domain computers
Else
'Msgbox "not empty"
If TypeName(colGroups) = "String" Then
'machine is only a member of one group other than its primary group, ie domain computers
strGroup = checkCN(LCase(colGroups))
If strGroup <> "" Then
If Not dicGroupNames.Exists(LCase(Trim(strGroup))) Then
dicGroupNames.Add LCase(Trim(strGroup)), "1"
Call LOG_BUFFER("+++ Adding Computer GroupName " & LCase(Trim(strGroup)) & " to dictionary +++", "file&eventlog", "file&eventlog")
Else
Call LOG_BUFFER("+++ Already have GroupName " & LCase(Trim(strGroup)) & " in dictionary, MGM +++", "file&eventlog", "file&eventlog")
End If
End If
'msgbox strGroup
Else
'machine is a member of more than one additional group other than its primary group, ie domain computers
For v = 0 To UBound(colGroups)
strGroup = checkCN(LCase(colGroups(v)))
If strGroup <> "" Then
If Not dicGroupNames.Exists(LCase(Trim(strGroup))) Then
dicGroupNames.Add LCase(Trim(strGroup)), "1"
Call LOG_BUFFER("+++ Adding Computer GroupName " & LCase(Trim(strGroup)) & " to dictionary +++", "file&eventlog", "file&eventlog")
Else
Call LOG_BUFFER("+++ Already have GroupName " & LCase(Trim(strGroup)) & " in dictionary, MGM +++", "file&eventlog", "file&eventlog")
End If
End If
'msgbox strGroup
Next
End If
End If
 
MrMovie,

Excellent - exactly what I wanted !!

Thanks very much to all posters who responded

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top