def create(self, tenant, people): """create a people Args: peole: a People instance """ dn = basedn.people_dn(people.username, tenant_name=tenant) attrs = {} attrs['objectclass'] = ['inetOrgPerson'] attrs["uid"] = people.username attrs['sn'] = people.last_name attrs['givenName'] = people.first_name if self.is_ascii(people.first_name) or self.is_ascii(people.last_name): # english name attrs['cn'] = "%s %s" % (people.first_name, people.last_name) else: # chinese name attrs['cn'] = "%s%s" % (people.first_name, people.last_name) attrs['description'] = "%s profile." % attrs['cn'] attrs['userPassword'] = people.pwd attrs['mail'] = [people.email] attrs['telephoneNumber'] = [people.tel] # use customized mobile number # attrs['mobileTelephoneNumber'] = [people.mobile] attrs['mobile'] = [people.mobile] self._client.add_entry(dn, attrs)
def delete(self, username, tenant_name): """delete a Subject""" dn = basedn.people_dn(username, tenant_name) self._client.delete_entry(dn)
def exists_user(self, tenant_name, username): """check if a user exists""" base = basedn.people_dn(username, tenant_name) return self.exists_entry(base)
def dn(self, tenant): return basedn.people_dn(self.username, tenant_name=tenant)
def search_user_entryuuid(self, tenant_name, username): """search an user's entryuuid""" dn = basedn.people_dn(username, tenant_name) return self.search_entry_uuid(dn)