我正在使用这个 VBS 将用户的平面列表从一个组移动到另一个组。到目前为止,一切都很好。我是 VB 的菜鸟。挑战在于我有 20 个不同的同步组 (Sync01-Sync20) 和 20 个 Mig 组 (Mig01-Mig20)。我需要扩展识别用户所属的女巫 Sunc 组的代码。然后将其“翻译”为正确的 Mig 组。任何人?:)
DIM objGroup, objGroup2, objRootLDAP, objFSO, objInput, objConnection, objCommand
DIM strUser
On Error Resume Next
Set objRootLDAP = GetObject("LDAP://rootDSE")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objInput = objFSO.OpenTextFile("users.txt")
Set objGroup = GetObject("LDAP://cn=Sync01,ou=Huset,dc=bb,dc=net")
Set objGroup2 = GetObject("LDAP://cn=Mig01,ou=Huset,dc=bb,dc=net")
Do Until objInput.AtEndOfStream
strUser = ObjInput.ReadLine
objCommand.CommandText = "<LDAP://dc=bb,dc=net>;(&(objectCategory=person)(sAMAccountName=" & strUser & "));distinguishedName,userAccountControl;subtree"
Set objRecordSet = objCommand.Execute
If objRecordSet.RecordCount = 0 Then
MsgBox strUser & " was not found!" & VbCrLf & "Skipping", VbOkOnly,"User Not Found"
Else
strDN = objRecordSet.Fields("distinguishedName")
Set objUser = GetObject("LDAP://" & strDN)
objGroup.Remove(objUser.AdsPath)
objGroup2.Add(objUser.AdsPath)
End If
Loop
WScript.Echo "Complete"