Jun-28-2024, 03:54 PM
alright done
you have enbtered in old password incorrect, or
you cant re-use an old existing password for your new password
so how do i return different errors ie show on the web page depending on what the stderr is
try: result = subprocess.run(f'powershell.exe $cred = Import-CliXml -Path C:\\python\\cred.xml; Set-ADAccountPassword -Credential $cred -Identity {form.un.data} -OldPassword (ConvertTo-SecureString -AsPlainText {form.op.data} -Force) -NewPassword (ConvertTo-SecureString -AsPlainText {form.cnp.data} -Force) -Server {form.dom.data}', check=True, capture_output=True, text=True, shell=False) return '<h1>The username is {}. The old password is {}. the new password is {}. changing for domain {}'.format(form.un.data, form.op.data, form.cnp.data, form.dom.data) except: return 'Something went wrong, Either current password was incorrect or re-using old password history for new password is not allowed, please try again' return render_template('password.html', form=form)but now the stderror could be two things, either
you have enbtered in old password incorrect, or
you cant re-use an old existing password for your new password
so how do i return different errors ie show on the web page depending on what the stderr is