Hey folks,
I have the script below that adds the *computer* account to a security group
via "CSCRIPT.EXE AddGroup.vbs "Group Name". Could someone help me modify it
to add a user to the same group? The user would be a task sequence variable
(OSDUser or whatever). Thanks in advance!
Const ADS_PROPERTY_APPEND = 3
Set WshShell = WScript.CreateObject("WScript.Shell")
'----Get Computer DN------
Set objADSysInfo = CreateObject("ADSystemInfo")
ComputerDN = objADSysInfo.ComputerName
strcomputerdn = "LDAP://" & computerDN
Set objADSysInfo = Nothing
'----Connect AD-----
Set oRoot = GetObject("LDAP://rootDSE")
strDomainPath = oRoot.Get("defaultNamingContext")
Set oConnection = CreateObject("ADODB.Connection")
oConnection.Provider = "ADsDSOObject"
oConnection.Open "Active Directory Provider"
Count = WScript.Arguments.Count
For i = 0 To count-1
Group = WScript.Arguments(i)
Addgroup Group
Next
'----Get Group DN------
Function Addgroup(groupname)
Set oRs = oConnection.Execute("SELECT adspath FROM 'LDAP://"
& strDomainPath & "'" & "WHERE objectCategory='group' AND " & "Name='" &
GroupName & "'")
If Not oRs.EOF Then
strAdsPath = oRs("adspath")
End If
If IsEmpty(strAdsPath) = False Then
Const ADS_SECURE_AUTHENTICATION = 1
Set objGroup = GetObject(stradspath)
Set objComputer = GetObject(strComputerDN)
If (objGroup.IsMember(objComputer.AdsPath) =
False) Then
objGroup.PutEx
ADS_PROPERTY_APPEND, "member", Array(computerdn)
objGroup.SetInfo
End If
End If
End Function
Best Regards,
Mike Murray
Desktop Management Coordinator - IT Support Services
California State University, Chico
530.898.4357
<mailto:[email protected]> [email protected]
Remember, Chico State will NEVER ask you for your password via email!
For more information about recognizing phishing scam emails go to:
<http://www.csuchico.edu/isec/basics/spam-and-phishing.shtml>
http://www.csuchico.edu/isec/basics/spam-and-phishing.shtml
smime.p7s
Description: S/MIME cryptographic signature

