<s> from ldap3 import Server , Connection , ALL <EOL> """<STR_LIT>""" <EOL> def rotate ( record , newpassword ) : <EOL> result = False <EOL> host = record . get ( '<STR_LIT>' ) <EOL> user_dn = record . get ( '<STR_LIT>' ) <EOL> try : <EOL> server = Server ( <EOL> host = host , <EOL> use_ssl = True , <EOL> get_info = ALL ) <EOL> conn = Connection ( <EOL> server = server , <EOL> user = user_dn , <EOL> password = record . password , <EOL> auto_bind = True ) <EOL> changePwdResult = conn . extend . microsoft . modify_password ( user_dn , newpassword ) <EOL> if ( changePwdResult == True ) : <EOL> print ( '<STR_LIT>' ) <EOL> record . password = newpassword <EOL> result = True <EOL> else : <EOL> print ( "<STR_LIT>" % ( changePwdResult ) ) <EOL> conn . unbind ( ) <EOL> except : <EOL> print ( "<STR_LIT>" ) <EOL> return result </s>
