ajalboush
asked on
Generate Random passwords for domain users ?
we are migrating our domain from 2000 to 2003, we have created new users accounts and now we need to generate new random passwords for the users?
is there a tool.. script... that can be used to create the random password for the users, since i do not want to reset them all to a common password .
i need to have for each user random password ?
is there a tool.. script... that can be used to create the random password for the users, since i do not want to reset them all to a common password .
i need to have for each user random password ?
Good link indeed !
Here's another one to an installable version (can be helpful if no Inet is available)
http://www.snapfiles.com/download/dlranpass.html
HTH
Cheers
Here's another one to an installable version (can be helpful if no Inet is available)
http://www.snapfiles.com/download/dlranpass.html
HTH
Cheers
you can perform those tasks with the following vbScript:
__________________________ __________ _
Option Explicit
Dim Title, NumChar, Count, strRdm, intRdm, i, strNewPassword, dtStart
Dim strUserName, objConnection, objCommand, objRecordSet, objUser
strUserName = InputBox("Please enter the Username (samAccountName)", "Provide the Username", "MarkusK")
ResetPassword(CheckForUser (strUserNa me))
Function CheckForUser(samAccountNam e)
dtStart = TimeValue(Now())
strUserName = samAccountName
Set objConnection = CreateObject("ADODB.Connec tion")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Comman d")
objCommand.ActiveConnectio n = objConnection
'**** - Replace dc=fabrikam,dc=com with your Domain
objCommand.CommandText = "<LDAP://dc=fabrikam,dc=co m>;(&(obje ctCategory =User)" & _
"(samAccountName=" & strUserName & "));samAccountName,disting uishedName ;subtree"
Set objRecordSet = objCommand.Execute
If objRecordset.RecordCount = 0 Then
WScript.Echo "sAMAccountName: " & strUserName & " does not exist."
Wscript.quit
Else
CheckForUser = objRecordSet.Fields(1)
End If
objConnection.Close
End Function
Sub ResetPassword(ByVal strUserDN)
WScript.Echo strUserDN
'**** - Define the new password
strNewPassword = CreateRandomPassword
'**** - Bind to the AD User Object
Set objUser = GetObject("LDAP://" & strUserDN)
'**** - Reset the password
'objUser.SetPassword strNewPassword
'**** - Delete the Script-Object
Set objUser = Nothing
WScript.Echo "The Password for User " & strUserName & " (" & strUserDN & ") has been set to: " & strNewPassword
End Sub
Function CreateRandomPassword()
'**** - Set the password length, e.g. 8 characters
NumChar = 8
'**** - Perform a "real" randomize
Randomize Timer
'**** - Generate Password
Do Until Count = NumChar
Count = Count + 1
GetRdm
strRdm = strRdm & Chr(intRdm)
Loop
'**** - Return the value
CreateRandomPassword = strRdm
End Function
Sub GetRdm
intRdm = Int((122 - 49) * Rnd + 48)
'**** - Enable the next line to get only alphanumeric passwords; otherwise you get complex passwords
If intRdm > 57 And intRdm < 65 Or intRdm > 90 And intRdm < 97 Then GetRdm
End Sub
__________________________
Option Explicit
Dim Title, NumChar, Count, strRdm, intRdm, i, strNewPassword, dtStart
Dim strUserName, objConnection, objCommand, objRecordSet, objUser
strUserName = InputBox("Please enter the Username (samAccountName)", "Provide the Username", "MarkusK")
ResetPassword(CheckForUser
Function CheckForUser(samAccountNam
dtStart = TimeValue(Now())
strUserName = samAccountName
Set objConnection = CreateObject("ADODB.Connec
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Comman
objCommand.ActiveConnectio
'**** - Replace dc=fabrikam,dc=com with your Domain
objCommand.CommandText = "<LDAP://dc=fabrikam,dc=co
"(samAccountName=" & strUserName & "));samAccountName,disting
Set objRecordSet = objCommand.Execute
If objRecordset.RecordCount = 0 Then
WScript.Echo "sAMAccountName: " & strUserName & " does not exist."
Wscript.quit
Else
CheckForUser = objRecordSet.Fields(1)
End If
objConnection.Close
End Function
Sub ResetPassword(ByVal strUserDN)
WScript.Echo strUserDN
'**** - Define the new password
strNewPassword = CreateRandomPassword
'**** - Bind to the AD User Object
Set objUser = GetObject("LDAP://" & strUserDN)
'**** - Reset the password
'objUser.SetPassword strNewPassword
'**** - Delete the Script-Object
Set objUser = Nothing
WScript.Echo "The Password for User " & strUserName & " (" & strUserDN & ") has been set to: " & strNewPassword
End Sub
Function CreateRandomPassword()
'**** - Set the password length, e.g. 8 characters
NumChar = 8
'**** - Perform a "real" randomize
Randomize Timer
'**** - Generate Password
Do Until Count = NumChar
Count = Count + 1
GetRdm
strRdm = strRdm & Chr(intRdm)
Loop
'**** - Return the value
CreateRandomPassword = strRdm
End Function
Sub GetRdm
intRdm = Int((122 - 49) * Rnd + 48)
'**** - Enable the next line to get only alphanumeric passwords; otherwise you get complex passwords
If intRdm > 57 And intRdm < 65 Or intRdm > 90 And intRdm < 97 Then GetRdm
End Sub
you can also write the whole list of usernames - passwords into a text file, excel, or whatever you wish.
let me know if you need further assistance.
ATB
Markus
let me know if you need further assistance.
ATB
Markus
one thing I forgot while testing:
you'll have to remove the ' in the line:
'objUser.SetPassword strNewPassword
in order to set the password
Otherwise the script only SAYS that the password was reset.
;-)
ATB
Markus
you'll have to remove the ' in the line:
'objUser.SetPassword strNewPassword
in order to set the password
Otherwise the script only SAYS that the password was reset.
;-)
ATB
Markus
Excellent script, Markus ! I'll definitely keep it !
Cheers
Cheers
(: THXS :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.winguides.com/security/password.php
Hope this helps!
:o)
Bartender_1