AD vbs script fejl - memberOf
Hej jeg har lavet dette vbs script som "forbinder" til et excel ark med de pågældene data, og skriver dem ind i Active directory på en 2003 server.Alt kører fint lige indtil at den kommer til "memberOf", den siger: "Serveren vil ikke udføre anmodningen".
Excel arket burde også være i orden, da indholdet i cellen er:
CN=IT-afdelingen,OU=IT,OU=Brugere,DC=domain,DC=local
IT-afdelingen er navnet på gruppen i active directoriet(den er oprettet)
Hvad kan fejlen skylder, eller kan det simpelthen ikke lade sig gøre?
----------------------------------------------------------
Dim objRootLDAP, objContainer, objUser, objShell
Dim objExcel, objSpread, intRow
Dim strUser, strOU, strSheet
Dim strCN, strSam, strFirst, strLast, strPWD, strdisplayName, struserPrincipalName, strinitials, strmemberOf
strOU = "OU=IT, OU=Brugere ," ' Note the comma
strSheet = "C:\Active Directory\Brugere\IT3.xls"
Set objRootLDAP = GetObject("LDAP://rootDSE")
Set objContainer = GetObject("LDAP://" & strOU & _
objRootLDAP.Get("defaultNamingContext"))
Set objExcel = CreateObject("Excel.Application")
Set objSpread = objExcel.Workbooks.Open(strSheet)
intRow = 3 'Row 1 often contains headings
Do Until objExcel.Cells(intRow, 1).Value = ""
strFirst = Trim(objExcel.Cells(intRow, 1).Value)
strLast = Trim(objExcel.Cells(intRow, 3).Value)
strSam = Trim(objExcel.Cells(intRow, 4).Value)
strCN = Trim(objExcel.Cells(intRow, 5).Value)
strPWD = Trim(objExcel.Cells(intRow, 6).Value)
strdisplayName = Trim(objExcel.Cells(intRow, 7).Value)
struserPrincipalName = Trim(objExcel.Cells(intRow, 8).Value)
strmemberOf = Trim(objExcel.Cells(intRow, 9).Value)
strinitials = Trim(objExcel.Cells(intRow, 10).Value)
Set objUser = objContainer.Create("User", "cn=" & strCN)
objUser.sAMAccountName = strSam
objUser.givenName = strFirst
objUser.sn = strLast
objUser.displayName = strdisplayName
objUser.userPrincipalName = struserPrincipalName
objUser.initials = strinitials
objUser.memberOf = strmemberOf
objUser.SetInfo
objUser.userAccountControl = 512
objUser.pwdLastSet = 0
objUser.SetPassword strPWD
objUser.SetInfo
intRow = intRow + 1
Loop
objExcel.Quit
WScript.Quit
---------------------------------------------------
