Skip to content
Snippets Groups Projects
Commit 3946dc40 authored by sveseli's avatar sveseli
Browse files

fix issue with unicode strings, which ldap apparently cannot handle

parent 7dcefebe
No related branches found
No related tags found
No related merge requests found
......@@ -86,6 +86,7 @@ class LdapLinuxPlatformUtility:
""" Create group if it does not exist. """
logger = self.getLogger()
ldapClient = self.getLdapClient()
name = str(name)
try:
groupDn = self.groupDnFormat % name
logger.debug('Looking for group DN: %s' % groupDn)
......@@ -138,6 +139,8 @@ class LdapLinuxPlatformUtility:
""" Add user to group. """
logger = self.getLogger()
ldapClient = self.getLdapClient()
username = str(username)
groupName = str(groupName)
try:
groupDn = self.groupDnFormat % groupName
resultList = ldapClient.search_s(groupDn, ldap.SCOPE_BASE)
......@@ -181,7 +184,7 @@ class LdapLinuxPlatformUtility:
if __name__ == '__main__':
utility = LdapLinuxPlatformUtility('ldaps://dmid-vm.xray.aps.anl.gov:636', 'uid=dmadmin,ou=People,o=aps.anl.gov,dc=aps,dc=anl,dc=gov', '/tmp/ldapPassword', groupDnFormat='cn=%s,ou=DM,ou=Group,o=aps.anl.gov,dc=aps,dc=anl,dc=gov', minGidNumber=66000)
utility.createGroup('exp2')
utility.createGroup(u'exp9')
#utility.createGroup('dmgp000001_TOF')
utility.addUserToGroup('rs1', 'exp2')
utility.addUserToGroup(u'rs1', u'exp9')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment