def from_ldap_map(self, ldap_map): for dn_path in ldap.dn.explode_dn(ldap_map[0], ldap.DN_FORMAT_LDAPV3): self.dn.append(dn_path.decode("utf-8")) self.string_dn = ldap_map[0].decode("utf-8") ldap_map = ldap_map[1] # в нулевом элементе содержится dn temp = commonldap.get_ldap_attribute_first(ldap_map, user_attr_map["uid"]) if temp: self.cn = temp self.uid = temp #!!! пока совпадает с cn'ом temp = commonldap.get_ldap_attribute_first(ldap_map, user_attr_map["name"]) if temp: self.name = temp.decode("UTF-8") # ФИО человека :) temp = commonldap.get_ldap_attribute_first(ldap_map, user_attr_map["password"]) if temp: self.password = temp.decode("utf-8") temp = commonldap.get_ldap_attribute(ldap_map, user_attr_map["member_of"]) if temp: self._member_of = temp temp = commonldap.get_ldap_attribute_first(ldap_map, user_attr_map["email"]) if temp: self.email = temp.decode("utf-8") temp = commonldap.get_ldap_attribute_first(ldap_map, user_attr_map["phone"]) if temp: self.phone = temp.decode("utf-8") temp = commonldap.get_ldap_attribute_first(ldap_map, user_attr_map["description"]) if temp: self.description = temp.decode("utf-8") temp = commonldap.get_ldap_attribute(ldap_map, user_attr_map["ldap_object_class"]) if temp: self.ldap_object_classes = temp return self
def from_ldap_map(self, ldap_map): self.string_dn = ldap_map[0] self.dn = ldap.dn.explode_dn(ldap_map[0],ldap.DN_FORMAT_LDAPV3) for dn_path in ldap.dn.explode_dn(ldap_map[0],ldap.DN_FORMAT_LDAPV3): self.dn.append(dn_path.decode('utf-8')) self.string_dn = ldap_map[0].decode('utf-8') ldap_map = ldap_map[1] #в нулевом элементе содержится dn temp = get_ldap_attribute_first(ldap_map, org_attr_map['o']) if temp : self.o = temp.decode('utf-8') temp = get_ldap_attribute_first(ldap_map, org_attr_map['display_name']) if temp: self.display_name = temp.decode('utf-8') # temp = get_ldap_attribute_first(ldap_map, org_attr_map['country']) # if temp: # self.country = temp.decode('utf-8') # # temp = get_ldap_attribute_first(ldap_map, org_attr_map['code']) # if temp: # self.code = temp.decode('utf-8') # # temp = get_ldap_attribute_first(ldap_map, org_attr_map['district']) # if temp: # self.district = temp.decode('utf-8') # # temp = get_ldap_attribute_first(ldap_map, org_attr_map['http_service']) # if temp: # self.http_service = temp # else: # self.http_service = '' # # temp = get_ldap_attribute_first(ldap_map, org_attr_map['edd_service']) # if temp: # self.edd_service = temp # # temp = get_ldap_attribute_first(ldap_map, org_attr_map['ill_service']) # if temp: # self.ill_service = temp # # temp = get_ldap_attribute_first(ldap_map, org_attr_map['location']) # if temp: # self.location = temp # # temp = get_ldap_attribute_first(ldap_map, org_attr_map['phone']) # if temp: # self.phone = temp # # temp = get_ldap_attribute_first(ldap_map, org_attr_map['email']) # if temp: # self.email = temp # # temp = get_ldap_attribute(ldap_map, org_attr_map['email_access']) # if temp: # self.email_access = temp # # temp = get_ldap_attribute(ldap_map, org_attr_map['plans']) # if temp: # self.plans = temp[0] # # temp = get_ldap_attribute(ldap_map, org_attr_map['postal_address']) # if temp: # self.postal_address = temp # # temp = get_ldap_attribute(ldap_map, org_attr_map['osi_latitude']) # if temp: # self.osi_latitude = temp # # temp = get_ldap_attribute(ldap_map, org_attr_map['osi_longitude']) # if temp: # self.osi_longitude = temp temp = get_ldap_attribute(ldap_map, org_attr_map['member_of']) if temp: for memeber in temp: self._member_of.append(memeber.decode('utf-8')) temp = get_ldap_attribute(ldap_map, org_attr_map['weight']) if temp: weight = 0 try: weight = int(temp[0]) except Exception: pass self.weight = weight else: self.weight = 0 temp = get_ldap_attribute(ldap_map, org_attr_map['ldap_object_class']) if temp: self.ldap_object_classes = temp return self