Advertisement
Advertisement
| 06.06.2008 at 03:04AM PDT, ID: 23463156 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: |
Dim pUsername
Dim pPassword
if WScript.Arguments.Named.Item ("pUsername") <> "" then pUsername = WScript.Arguments.Named.Item ("pUsername") else pUsername = "-"
if WScript.Arguments.Named.Item ("pPassword") <> "" then pPassword = WScript.Arguments.Named.Item ("pPassword") else pPassword = "password"
'Find the OU of the user passed as pUsername
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Properties("User ID") = "domain\domainadminuser"
objConnection.Properties("Password") = "theirpassword"
objConnection.Properties("Encrypt Password") = TRUE
objConnection.Properties("ADSI Flag") = 3
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT distinguishedName FROM 'LDAP://dc=domain,dc=local' WHERE objectCategory='user' " & _
"AND sAMAccountName='" & pUsername & "'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
vOU = objRecordSet.Fields("distinguishedName").Value
objRecordSet.MoveNext
Loop
' End find OU
' Reset the password of the user
Set objUser = GetObject ("LDAP://" & vOU)
'Set the user's initial password
objUser.SetPassword pPassword
objUser.Put "pwdLastSet", "0"
'Commit changes to directory
objUser.SetInfo
|