VBSCript To Modify Active Directory User Properties
VBSCript To Modify Active Directory User Properties
Const ADS_PROPERTY_UPDATE = 2
'Read CSV
Set objCSVFile = objFSO.OpenTextFile("UserInfo.csv",1)
arrStr = split(objCSVFile.ReadLine,",")
if ou = "" then
wscript.echo strFullName
else
i = 0
Set objUser = GetObject("LDAP://cn=" & strFullName & "," & _
ou & "")
do while i < 1
If err.number <> 0 then
wscript.echo "Error: " & strFullName & " " & _
err.number
else
'Set the attribute values
objUser.Put "streetAddress", strAddress1 & vbCrLf & _
strAddress2
objUser.Put "l", strCity
objUser.Put "st", strState
objUser.Put "postalCode", strZip
objUser.Put "telephoneNumber", strTelephone
objUser.Put "mail", strEmail
'Set the user info
objUser.SetInfo
end if
i = i + 1
loop
end if
n = 0
Loop
objCSVFile.Close
set cn = createobject("ADODB.Connection")
set cmd = createobject("ADODB.Command")
cn.open "Provider=ADsDSOObject;"
cmd.activeconnection = cn
cmd.commandtext = ldapFilter
set rs = cmd.execute
end if
rs.close
cn.close
end function