Jump to content

Endot

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by Endot

  1. Got it worked out. There were a number of things I was doing incorrectly actually, mainly how I was attempting to target users using _AD_FQDNToSamAccountName when I'd already gotten their SamAccountname. Finished script: #include <AD.au3> ; Open Connection to the Active Directory _AD_Open("Administrator", "password") If @error Then Exit MsgBox(16, "Active Directory Master Password Reset", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended) Global $iReply = MsgBox(308, "Active Directory Master Password Reset", "This script changes the password for all Users in the 'Quality' OU." & @CRLF & @CRLF & _ "Are you sure you want to change the Active Directory?") If $iReply <> 6 Then Exit Global $aUsers ;update target to the appropriate OU you wish to reset Global $sOU = "OU=Users,OU=Quality,OU=Engineering,DC=dev,DC=fbf" $aUsers = _AD_GetObjectsInOU($sOU, "(objectclass=user)", 2, "samaccountname") ;reset password loop FileWriteLine("log.txt", @Hour & ":" & @Min & ":" & @Sec & " - " & "Beginning Password Reset..." ) For $i = 1 to $aUsers[0] Global $iValue = _AD_SetPassword( $aUsers[$i], "demo") ; set password here If @error Then Exit FileWriteLine("log.txt", @Hour & ":" & @Min & ":" & @Sec & " - " "There was an issue changing the password for " & $aUsers[$i] & " - @error = " & @error & ", @extended = " & @extended) FileWriteLine("log.txt", @Hour & ":" & @Min & ":" & @Sec & " - " & $aUsers[$i] & "'s password changed to 'demo'" ) Next FileWriteLine("log.txt", @Hour & ":" & @Min & ":" & @Sec & " - " & "Ending Password Reset" ) Global $iReply = MsgBox(0, "Active Directory Master Password Reset", "Password Reset Successful") _AD_Close()
  2. Got it worked out. There was a number of things I was doing incorrectly actually, mainly how I was attempting to target users using _AD_FQDNToSamAccountName when I'd already gotten their SamAccountname. Finished script: ; Open Connection to the Active Directory _AD_Open("Administrator", "password") If @error Then Exit MsgBox(16, "Active Directory Master Password Reset", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended) Global $iReply = MsgBox(308, "Active Directory Master Password Reset", "This script changes the password for all Users in the 'Quality' OU." & @CRLF & @CRLF & _ "Are you sure you want to change the Active Directory?") If $iReply <> 6 Then Exit Global $aUsers[30] Global $sOU = "OU=Users,OU=Quality,OU=Engineering,DC=dev,DC=fbf" $aUsers = _AD_GetObjectsInOU($sOU, "(objectclass=user)", 2, "samaccountname") FileWriteLine("log.txt", @Hour & ":" & @Min & ":" & @Sec & " - " & "Beginning Password Reset..." ) For $i = 1 to $aUsers[0] Global $iValue = _AD_SetPassword($aUsers[$i], "demo") If @error Then Exit FileWriteLine("log.txt", @Hour & ":" & @Min & ":" & @Sec & " - " "There was an issue changing the password for " & $aUsers[$i] & " - @error = " & @error & ", @extended = " & @extended) FileWriteLine("log.txt", @Hour & ":" & @Min & ":" & @Sec & " - " & $aUsers[$i] & "'s password changed to 'demo'" ) Next FileWriteLine("log.txt", @Hour & ":" & @Min & ":" & @Sec & " - " & "Ending Password Reset" ) _AD_Close()
  3. I might have posted in the wrong thread :/ Here's the post:
  4. Hello! I'm trying to create a script to reset all users in a targeted OU to a preset password. I seem to be having issues in the loop section. #AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y ; ***************************************************************************** ; Sets the password for all users ; ***************************************************************************** #include <AD.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; Open Connection to the Active Directory _AD_Open("Administrator", "password") If @error Then Exit MsgBox(16, "Active Directory Master Password Reset", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended) Global $iReply = MsgBox(308, "Active Directory Master Password Reset", "This script changes the password for all Users in the 'Quality' OU." & @CRLF & @CRLF & _ "Are you sure you want to change the Active Directory?") If $iReply <> 6 Then Exit Global $aUsers Global $sOU = "OU=Users,OU=Quality,OU=Engineering,DC=dev,DC=fbf" $aUsers = _AD_GetObjectsInOU($sOU, "(objectclass=user)", 2, "name,samaccountname") _ArraySort($aUsers, 0, 1) For $i = 1 to $aUsers[0] Global $iValue = _AD_SetPassword( _AD_FQDNToSamAccountName($aUsers[$i]) & , "demo") If $iValue = 1 Then MsgBox(64, "Active Directory Functions - Set Password", "Password for user '" & $sUser & "' successfully changed") Else MsgBox(64, "Active Directory Functions - Set Password", "Return code '" & @error & "' from Active Directory") EndIf Next _AD_Close() The error I'm receiving: Any idea where I went wrong?
×
×
  • Create New...