def create(self, pid, **kw): # XXX: mechanism for defining a target container if scope is SUBTREE # create principal with LDAPNode as context context = LDAPNode() principal = self.principal_factory( context, attraliaser=self.principal_attraliaser ) # ensure id on attributes kw['id'] = pid # avoid overwriting key attribute if given in kw if self._key_attr in kw: del kw[self._key_attr] # set additional attributes on principal for k, v in kw.items(): principal.attrs[k] = v # set principal to self self[pid] = principal # if setting principal has been successful, hook up principal context # to ldap tree rdn = '{0}={1}'.format( self._rdn_attr, principal.context.attrs[self._rdn_attr] ) self.context[rdn] = context # return newly created principal return self[pid]
def __init__(self, props, cfg): context = LDAPNode(name=cfg.baseDN, props=props) context.search_filter = cfg.queryFilter context.search_scope = int(cfg.scope) context.child_defaults = dict() context.child_defaults['objectClass'] = cfg.objectClasses context.child_defaults.update(cfg.defaults) for oc in cfg.objectClasses: for key, val in creation_defaults.get(oc, dict()).items(): if key not in context.child_defaults: context.child_defaults[key] = val # if cfg.member_relation: # context.search_relation = cfg.member_relation self._rdn_attr = cfg.attrmap['rdn'] self._key_attr = cfg.attrmap['id'] if self._key_attr not in cfg.attrmap: cfg.attrmap[self._key_attr] = self._key_attr self._login_attr = None if cfg.attrmap.get('login') \ and cfg.attrmap['login'] != cfg.attrmap['id']: self._login_attr = cfg.attrmap['login'] self.expiresAttr = getattr(cfg, 'expiresAttr', None) self.expiresUnit = getattr(cfg, 'expiresUnit', None) self.principal_attrmap = cfg.attrmap self.principal_attraliaser = DictAliaser(cfg.attrmap, cfg.strict) self.context = context
def __init__(self, props, cfg): context = LDAPNode(name=cfg.baseDN, props=props) context.search_filter = cfg.queryFilter context.search_scope = int(cfg.scope) context.child_defaults = dict() context.child_defaults["objectClass"] = cfg.objectClasses context.child_defaults.update(cfg.defaults) for oc in cfg.objectClasses: for key, val in creation_defaults.get(oc, dict()).items(): if key not in context.child_defaults: context.child_defaults[key] = val # if cfg.member_relation: # context.search_relation = cfg.member_relation self._rdn_attr = cfg.attrmap["rdn"] self._key_attr = cfg.attrmap["id"] if self._key_attr not in cfg.attrmap: cfg.attrmap[self._key_attr] = self._key_attr self._login_attr = None if cfg.attrmap.get("login") and cfg.attrmap["login"] != cfg.attrmap["id"]: self._login_attr = cfg.attrmap["login"] self.expiresAttr = getattr(cfg, "expiresAttr", None) self.expiresUnit = getattr(cfg, "expiresUnit", None) self.principal_attrmap = cfg.attrmap self.principal_attraliaser = DictAliaser(cfg.attrmap, cfg.strict) self.context = context
def __init__(self, props, cfg): context = LDAPNode(name=cfg.baseDN, props=props) context.search_filter = cfg.queryFilter context.search_scope = int(cfg.scope) context.child_defaults = dict() context.child_defaults['objectClass'] = cfg.objectClasses if hasattr(cfg, 'defaults'): context.child_defaults.update(cfg.defaults) for oc in cfg.objectClasses: for key, val in creation_defaults.get(oc, dict()).items(): if not key in context.child_defaults: context.child_defaults[key] = val # XXX: make these attrs public context._key_attr = cfg.attrmap['id'] context._rdn_attr = cfg.attrmap['rdn'] #if cfg.member_relation: # context.search_relation = cfg.member_relation context._seckey_attrs = ('dn',) if cfg.attrmap.get('login') \ and cfg.attrmap['login'] != cfg.attrmap['id']: context._seckey_attrs += (cfg.attrmap['login'],) context._load_keys() self.expiresAttr = getattr(cfg, 'expiresAttr', None) self.expiresUnit = getattr(cfg, 'expiresUnit', None) self.principal_attrmap = cfg.attrmap self.principal_attraliaser = DictAliaser(cfg.attrmap, cfg.strict) self.context = context