def node_attributes(self): dn = self.request["dn"] base = self.request["base"] if base == "users": users = ILDAPUsersConfig(self.plugin) baseDN = users.baseDN else: groups = ILDAPGroupsConfig(self.plugin) baseDN = groups.baseDN root = LDAPNode(baseDN, self.props) node = root.node_by_dn(safe_unicode(dn), strict=True) ret = dict() for key, val in node.attrs.items(): try: if not node.attrs.is_binary(key): ret[safe_unicode(key)] = safe_unicode(val) else: ret[safe_unicode(key)] = "(Binary Data with {0} Bytes)".format( len(val) ) except UnicodeDecodeError: ret[safe_encode(key)] = "! (UnicodeDecodeError)" except Exception: ret[safe_encode(key)] = "! (Unknown Exception)" return json.dumps(ret)
def node_attributes(self): dn = self.request["dn"] base = self.request["base"] if base == "users": users = ILDAPUsersConfig(self.plugin) baseDN = users.baseDN else: groups = ILDAPGroupsConfig(self.plugin) baseDN = groups.baseDN root = LDAPNode(baseDN, self.props) node = root.node_by_dn(safe_unicode(dn), strict=True) ret = dict() for key, val in node.attrs.items(): try: if not node.attrs.is_binary(key): ret[safe_unicode(key)] = safe_unicode(val) else: ret[safe_unicode( key)] = "(Binary Data with {0} Bytes)".format(len(val)) except UnicodeDecodeError: ret[safe_encode(key)] = "! (UnicodeDecodeError)" except Exception: ret[safe_encode(key)] = "! (Unknown Exception)" return json.dumps(ret)