0

I want to reset my MAC OSX password , for that i want a GUI. To do that i know in terminal we have to run the following command.

  Aug4-2:~ root# passwd
  Changing password for root
  New password:
  Retype new password:

For this i want to provide a user interface, where user can reset user password. We need to use NStask and NSpipe to do this task. If some one have the code snippet please post here

1
  • Can i know reason for down vote, so that i can rectify Commented Aug 6, 2015 at 5:14

1 Answer 1

1

Try Using apple script.

tell application "System Events"
    activate
    display dialog "Please enter your old Password:" default answer "" with title "Password Reset" with hidden answer
    set the PSWD0 to text returned of the result
end tell
tell application "System Events"
    activate
    display dialog "Please enter a new password:" default answer "" with title "Password Reset" with hidden answer
    set the PSWD1 to text returned of the result
end tell
tell application "System Events"
    activate
    display dialog "Please Re-enter a new password:" default answer "" with title "Password Reset" with hidden answer
    set the PSWD2 to text returned of the result
end tell
if PSWD1 = PSWD2 then
    if PSWD1 = PSWD0 then
        display dialog "Both passwords entered are same" with title "Password Reset"
    return

    end if
else
    display dialog "Re entered Password is different" with title "Password Reset"

    return
end if
try
    do shell script "dscl . -passwd  /Users/$User  " & quoted form of PSWD0 & "       " & quoted form of PSWD1 & " "

on error errMsg number errorNumber

    if 10 = errorNumber then
        display dialog "Old password entered is incorrect" with title "Password Reset"

        return
    else
        if 90 = errorNumber then
            display dialog "New password is not meeting password policy requirements, Password length is too small" with title "Password Reset"

            return
        else
            if 93 = errorNumber then
                display dialog "New password is not meeting password policy requirements ,It should consist of atleast one Numeric character" with title "Password Reset"

                return
            end if
        end if
    end if
    return
end try
display dialog "password is changed succesfully" with title "Password Reset"
return true
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.