Lines 217-228
def umc(username, password, master, path='', options=None, flavor=None, command=
|
Link Here
|
---|
|
217 |
|
217 |
|
218 |
def get_user_dn(username, password, master): |
218 |
def get_user_dn(username, password, master): |
219 |
"""Get the LDAP DN for the given username.""" |
219 |
"""Get the LDAP DN for the given username.""" |
220 |
result = umc(username, password, master, 'udm/query', {"objectProperty": "username", "objectPropertyValue": username}, 'users/user') |
220 |
ssh = get_ssh_connection(username, password, master) |
221 |
result = [ientry.get('$dn$') for ientry in result if ientry.get('username') == username] |
221 |
stdin, stdout, stderr = ssh.exec_command(' '.join([pipes.quote(x) for x in ['/usr/bin/sudo', '/usr/bin/univention-ldapsearch', '-LLLoldif-wrap=no', filter_format('(&(uid=%s)(objectClass=person))', [username]), 'dn']])) |
222 |
try: |
222 |
for line in stdout.splitlines(): |
223 |
return result[0] |
223 |
match = re.match('^dn: (.*)\s*$', line) |
224 |
except IndexError: |
224 |
if match: |
225 |
pass |
225 |
return match.group(1) |
226 |
|
226 |
|
227 |
|
227 |
|
228 |
def create_ou_local(ou, displayName): |
228 |
def create_ou_local(ou, displayName): |
Lines 579-584
class Instance(Base):
|
Link Here
|
---|
|
579 |
except univention.uldap.ldap.LDAPError as err: |
579 |
except univention.uldap.ldap.LDAPError as err: |
580 |
MODULE.warn('LDAP connection to %s failed: %s' % (master, err)) |
580 |
MODULE.warn('LDAP connection to %s failed: %s' % (master, err)) |
581 |
return {'success': False, 'error': _('The LDAP connection to the master system %s failed.') % master} |
581 |
return {'success': False, 'error': _('The LDAP connection to the master system %s failed.') % master} |
|
|
582 |
except socket.gaierror as exc: |
583 |
MODULE.warn('Could not connect to master system %s: %s' % (master, exc)) |
584 |
return {'success': False, 'error': _('Cannot connect to the master domain controller system %s. Please make sure that the system is reachable. If not this could be due to wrong DNS nameserver settings.') % master} |
585 |
except paramiko.SSHException as exc: |
586 |
MODULE.warn('Could not connect to master system %s: %s' % (master, exc)) |
587 |
return {'success': False, 'error': _('Cannot connect to the master domain controller system %s. It seems that the specified domain credentials are not valid.') % master} |
582 |
|
588 |
|
583 |
return {'success': True, 'schoolinfo': values} |
589 |
return {'success': True, 'schoolinfo': values} |
584 |
|
590 |
|