Open GokkulKumarVD opened 2 years ago
If you are Python 3.6 or higher you can use f-strings to create your DN value. If the value comes from an untrusted source you may first want to escape it with the ldap3.utils.conv.escape_filter_chars
function.
cnn = 'dummy'
conn.add(f'cn={cnn},ou=POC,dc=SWINTERNAL,dc=LOCAL', ...)
Or if using something less than 3.6 could use percent formatting:
cnn = 'dummy'
conn.add('cn=%s,ou=POC,dc=SWINTERNAL,dc=LOCAL' % cnn, ...)
When I pass the variable with the value, it is creating account in the name of variable, not the value of variable. Please help
import ldap3 conn = ldap3.Connection("172.16.251.61", "SWINTERNAL\ad.manager", "Adm@n@ger", auto_bind=True)
cnn = 'dummy'
conn.add('cn=cnn,ou=POC,dc=SWINTERNAL,dc=LOCAL', 'User', {'givenName': 'Beatrix', 'sn': 'Young', 'departmentNumber': 'DEV', 'telephoneNumber': 1111})