Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Listing AD Computer Group MembershipHelpful Member! 

Southpark (TechnicalUser)
21 Jun 06 7:04
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
markdmac (MIS)
27 Jun 06 0:03
Take a look at my FAQ FAQ329-5798 which shows how to get a users group memberships.  You can do the same for a machine account.

I hope you find this post helpful.  

Regards,

Mark

Check out my scripting solutions at http://www.thespidersparlor.com/vbscript

Southpark (TechnicalUser)
27 Jun 06 5:35
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
markdmac (MIS)
27 Jun 06 9:58
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 http://www.thespidersparlor.com/vbscript

Southpark (TechnicalUser)
29 Jun 06 11:22
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
Helpful Member!  mrmovie (TechnicalUser)
29 Jun 06 12:01
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
Southpark (TechnicalUser)
30 Jun 06 3:35
MrMovie,

Excellent - exactly what I wanted !!

Thanks very much to all posters who responded

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close