Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
'==========================================================================
'
' NAME: <CopyGroupsUserToUser.vbs>
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE : 2/6/2006
' COPYWRITE (C) 2003, All Rights Reserved
'
'
' COMMENT: <comment>
'
'==========================================================================
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
'Automatically find the domain name
Set objDomain = getObject("LDAP://rootDse")
DomainString = objDomain.Get("dnsHostName")
'Grab the user name
UserString1 = InputBox("Enter Template User Name", "Who should I copy?")
UserString2 = InputBox("Enter Target User Name", "Who should I add groups to?")
'Bind to the user object to get user name and check for group memberships later
Set UserObj1= GetObject("WinNT://" & DomainString & "/" & UserString1)
Set UserObj2= GetObject("WinNT://" & DomainString & "/" & UserString2)
For Each GroupObj In UserObj1.Groups
BindJoinUser(GroupObj.Name)
Next
Function BindJoinUser(GroupName)
GroupLDAP = SearchDistinguishedName(GroupName)
Set objGroup = GetObject("LDAP://" & GroupLDAP)
objGroup.Add UserObj2
End Function
Public Function SearchDistinguishedName(ByVal vSAN)
' Function: SearchDistinguishedName
' Description: Searches the DistinguishedName for a given SamAccountName
' Parameters: ByVal vSAN - The SamAccountName to search
' Returns: The DistinguishedName Name
Dim oRootDSE, oConnection, oCommand, oRecordSet
Set oRootDSE = GetObject("LDAP://rootDSE")
Set oConnection = CreateObject("ADODB.Connection")
oConnection.Open "Provider=ADsDSOObject;"
Set oCommand = CreateObject("ADODB.Command")
oCommand.ActiveConnection = oConnection
oCommand.CommandText = "<LDAP://" & oRootDSE.get("defaultNamingContext") & _
">;(&(objectCategory=Group)(samAccountName=" & vSAN & "));distinguishedName;subtree"
Set oRecordSet = oCommand.Execute
On Error Resume Next
SearchDistinguishedName = oRecordSet.Fields("DistinguishedName")
On Error GoTo 0
oConnection.Close
Set oRecordSet = Nothing
Set oCommand = Nothing
Set oConnection = Nothing
Set oRootDSE = Nothing
End Function