+ Post New Thread
Results 1 to 2 of 2
Windows Server 2000/2003 Thread, Change AD Users Primary Group in Technical; In order to support a large number of Macintosh clients, I need to change the Primary Group of most of ...
  1. #1

    Join Date
    Jan 2008
    Thank Post
    Thanked 0 Times in 0 Posts
    Rep Power

    Change AD Users Primary Group

    In order to support a large number of Macintosh clients, I need to change the Primary Group of most of my Active Directory users from Domain Users to one of three different user groups.

    This is easily done on a per user basis, but I am looking to make changes to thousands of users at a time.

    Does anyone have any experience with this and/or able to recommend a 3rd party app to get it done?

    Running Win2k3 Server

    Thanks in advance for any insight.

  2. #2
    bio is offline
    bio's Avatar
    Join Date
    Apr 2008
    Thank Post
    Thanked 130 Times in 102 Posts
    Rep Power
    I think you can use a portion of this script for your needs

    Set objRootLDAP = GetObject("LDAP://rootDSE")
    strOUPath = "OU=Kiosk Users,OU=Sites," & objRootLDAP.Get("defaultNamingContext")
    strNewPrimaryGroup = "CN=Kiosk_Users,OU=Kiosk Users,OU=Sites," & objRootLDAP.Get("defaultNamingContext")
    strOldPrimaryGroup = "CN=Domain Users,CN=Users," & objRootLDAP.Get("defaultNamingContext")
    Set objConnection = CreateObject("ADODB.Connection")
    Set objCommand =   CreateObject("ADODB.Command")
    objConnection.Provider = "ADsDSOObject"
    objConnection.Open "Active Directory Provider"
    Set objCommand.ActiveConnection = objConnection
    objCommand.Properties("Page Size") = 1000
    objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
    objCommand.CommandText = _
        "SELECT AdsPath FROM 'LDAP://" & strOUPath & "' WHERE objectClass='person' AND objectCategory='user'"  
    Set objRecordSet = objCommand.Execute
    While Not objRecordSet.EOF
    	Set objUser = GetObject(objRecordSet.Fields("adsPath").Value)
    	' Bind to the new primary group and add the user as a member, then set it as the primary group
    	Set objNewPrimaryGroup = GetObject("LDAP://" & strNewPrimaryGroup)
    	objNewPrimaryGroup.GetInfoEx Array("primaryGroupToken"), 0
    	objUser.primaryGroupID = objNewPrimaryGroup.primaryGroupToken
    	' Remove the user from the group that was the previous Primary group
    	Set objOldPrimaryGroup = GetObject("LDAP://" & strOldPrimaryGroup) 
    	objOldPrimaryGroup.Remove objUser.adsPath
    MsgBox "Finished."

+ Post New Thread

Similar Threads

  1. Replies: 6
    Last Post: 8th September 2009, 06:59 PM
  2. How to change display font size for all users of certain laptops?
    By HPitkin in forum Network and Classroom Management
    Replies: 2
    Last Post: 1st December 2008, 03:52 PM
  3. change taskbar back to blue group policy
    By cooper in forum Windows
    Replies: 5
    Last Post: 15th August 2007, 11:40 AM
  4. Change start page for logged on users
    By ajbritton in forum Comments and Suggestions
    Replies: 7
    Last Post: 12th April 2006, 09:48 AM
  5. Change profile path for all users
    By mark in forum Scripts
    Replies: 5
    Last Post: 10th September 2005, 07:16 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts