Reset expired password on connect
megadrifter opened this issue · 0 comments
megadrifter commented
There is need to change expired password on connect.
cx_Oracle allows to do this as described https://cx-oracle.readthedocs.io/en/latest/user_guide/connection_handling.html?highlight=newpassword%3D#resetting-passwords
I did not find implementation in Your modules.
Resetting Passwords
After connecting, passwords can be changed by calling Connection.changepassword():
# Get the passwords from somewhere, such as prompting the user
oldpwd = getpass.getpass("Old Password for %s: " % username)
newpwd = getpass.getpass("New Password for %s: " % username)
connection.changepassword(oldpwd, newpwd)
When a password has expired and you cannot connect directly, you can connect and change the password in one operation by using the newpassword parameter of the function cx_Oracle.connect() constructor:
# Get the passwords from somewhere, such as prompting the user
oldpwd = getpass.getpass("Old Password for %s: " % username)
newpwd = getpass.getpass("New Password for %s: " % username)
connection = cx_Oracle.connect(username, oldpwd, "dbhost.example.com/orclpdb1",
newpassword=newpwd, encoding="UTF-8")