I have written a Python script and I am using ldap3 module ( https://pypi.org/project/ldap3/) to add,modify attribute value in Oracle ldap.
I am able to modify ldap attribute values that don't have a single quote in it. However some users they have a single quote (') in their name. when I try to update displayname for a user who has a single quote. I get an error below
conn is connection to Oracle ldap
dipslayName is : O'Sry, Harry
result = conn.modify('uid=Harry12,ou=Corporate,ou=org,dc=axe,dc=com',{'displayName':[(ldap3.MODIFY_REPLACE,['O'Sry, Harry'])]})
Error:
File "<string>", line 1
{'displayName':[(ldap3.MODIFY_REPLACE,['O'Sry, Harry'])]}
^
SyntaxError: invalid syntax
I have already tried escaping using \ as below
{'displayName':[(ldap3.MODIFY_REPLACE,['O\'Sry, Harry'])]}
How do I escape single quotes in displayname in ldap3.MODIFY_REPLACE.