def adduser(self, name, surname, username, usersecret, expireDate, uidNo, badgenum):
if (self.userexistsbyuid(username) ):
print("User %s already exist!", username)
return
dn = "uid="+username+",ou=People,"+self.dc
attrs = {}
attrs['uid'] = username
attrs['userPassword'] = usersecret
attrs['givenName'] = name
attrs['sn'] = surname
attrs['cn'] = name+' '+surname
attrs['objectClass'] = ['person',
'organizationalPerson',
'inetOrgPerson',
'posixAccount',
'top',
'shadowAccount']
attrs['shadowMax'] = '99999'
attrs['shadowWarning'] = '7'
attrs['shadowExpire'] = expireDate
attrs['loginShell'] = '/bin/bash'
attrs['uidNumber'] = uidNo
attrs['gidNumber'] = '100'
attrs['homeDirectory'] = '/home/'+username
attrs['gecos'] = name+' '+surname+',,,,'+badgenum
attrs['employeeNumber'] = badgenum
attrs['mail'] = username+'@lcm.mi.infn.it'
# Convert our dict to nice syntax for the add-function using modlist-module
ldif = modlist.addModlist(attrs)
# Do the actual synchronous add-operation to the ldapuri
self.conn.add_s(dn,ldif)
评论列表
文章目录