Beispiel #1
0
    def __init__(self, principal, plugin):
        """Instanciate LDAPUserPropertySheet.

        @param principal: user id or group id
        @param plugin: LDAPPlugin instance
        """
        self._plugin = plugin
        self._properties = dict()
        if principal.getId() in plugin.users:
            self._pcfg = ILDAPUsersConfig(plugin)
            self._lprincipal = plugin.users[principal.getId()]
        else:
            self._pcfg = ILDAPGroupsConfig(plugin)
            self._lprincipal = plugin.groups[principal.getId()]
        
        self._attrmap = dict()
        for k, v in self._pcfg.attrmap.items():
            if k in ['rdn', 'id']:
                # XXX: maybe 'login' should be editable if existent ??
                continue
            self._attrmap[k] = v

        # XXX: tmp - load props each time they are accessed.
        if not self._plugin.REQUEST.get('_ldap_props_reloaded'):
            self._lprincipal.attrs.context.load()
            self._plugin.REQUEST['_ldap_props_reloaded'] = 1

        for key in self._attrmap:
            self._properties[key] = self._lprincipal.attrs.get(key, '')
        UserPropertySheet.__init__(self, principal, schema=None, 
                                   **self._properties)
Beispiel #2
0
    def __init__(self, principal, plugin):
        """Instanciate LDAPUserPropertySheet.

        @param principal: user id or group id
        @param plugin: LDAPPlugin instance
        """
        # do not set any non-pickable attribute here, i.e. acquisition wrapped
        self._plugin = aq_base(plugin)
        self._properties = dict()
        self._attrmap = dict()
        self._ldapprincipal_id = principal.getId()
        if self._ldapprincipal_id in plugin.users:
            pcfg = ILDAPUsersConfig(plugin)
            self._ldapprincipal_type = 'users'
        else:
            pcfg = ILDAPGroupsConfig(plugin)
            self._ldapprincipal_type = 'groups'
        for k, v in pcfg.attrmap.items():
            if k in ['rdn', 'id']:
                # XXX: maybe 'login' should be editable if existent ??
                continue
            self._attrmap[k] = v
        ldapprincipal = self._get_ldap_principal()
        request = getRequest()
        # XXX: tmp - load props each time they are accessed.
        if not request or not request.get('_ldap_props_reloaded'):
            ldapprincipal.attrs.context.load()
            if request:
                request['_ldap_props_reloaded'] = 1
        for key in self._attrmap:
            self._properties[key] = ldapprincipal.attrs.get(key, '')
        UserPropertySheet.__init__(self, principal.getId(), schema=None,
                                   **self._properties)
Beispiel #3
0
    def __init__(self, principal, plugin):
        """Instanciate LDAPUserPropertySheet.

        @param principal: user id or group id
        @param plugin: LDAPPlugin instance
        """
        # do not set any non-pickable attribute here, i.e. acquisition wrapped
        self._plugin = aq_base(plugin)
        self._properties = dict()
        self._attrmap = dict()
        self._ldapprincipal_id = principal.getId()
        if self._ldapprincipal_id in plugin.users:
            pcfg = ILDAPUsersConfig(plugin)
            self._ldapprincipal_type = 'users'
        else:
            pcfg = ILDAPGroupsConfig(plugin)
            self._ldapprincipal_type = 'groups'
        for k, v in pcfg.attrmap.items():
            if k in ['rdn', 'id']:
                # XXX: maybe 'login' should be editable if existent ??
                continue
            self._attrmap[k] = v
        ldapprincipal = self._get_ldap_principal()
        request = getRequest()
        # XXX: tmp - load props each time they are accessed.
        if not request or not request.get('_ldap_props_reloaded'):
            ldapprincipal.attrs.context.load()
            if request:
                request['_ldap_props_reloaded'] = 1
        for key in self._attrmap:
            self._properties[key] = ldapprincipal.attrs.get(key, '')
        UserPropertySheet.__init__(self,
                                   principal.getId(),
                                   schema=None,
                                   **self._properties)
    def __init__(self, id, user):
        self.id = id

        acl = self._getLDAPUserFolder(user)
        self._ldapschema = [
            (x["ldap_name"], x["public_name"], x["multivalued"] and "lines" or "string")
            for x in acl.getSchemaConfig().values()
            if x["public_name"]
        ]

        properties = self._getCache(user)
        if properties is None:
            properties = self.fetchLdapProperties(user)
            if properties:
                self._setCache(user, properties)

        UserPropertySheet.__init__(self, id, schema=[(x[1], x[2]) for x in self._ldapschema], **properties)
Beispiel #5
0
    def __init__(self, id, user):
        self.id=id

        acl = self._getLDAPUserFolder(user)
        self._ldapschema=[(x['ldap_name'], x['public_name'],
                        x['multivalued'] and 'lines' or 'string') \
                    for x in acl.getSchemaConfig().values() \
                    if x['public_name']]

        properties=self._getCache(user)
        if properties is None:
            properties=self.fetchLdapProperties(user)
            if properties:
                self._setCache(user, properties)

        UserPropertySheet.__init__(self, id,
                schema=[(x[1],x[2]) for x in self._ldapschema], **properties)
    def __init__(self, id, user):
        self.id = id

        acl = self._getLDAPUserFolder(user)
        self._ldapschema=[(x['ldap_name'], x['public_name'],
                        x['multivalued'] and 'lines' or 'string') \
                    for x in acl.getSchemaConfig().values() \
                    if x['public_name']]

        properties = self._getCache(user)
        if properties is None:
            properties = self.fetchLdapProperties(user)
            if properties:
                self._setCache(user, properties)

        UserPropertySheet.__init__(self,
                                   id,
                                   schema=[(x[1], x[2])
                                           for x in self._ldapschema],
                                   **properties)
def __patched_init__(self, id, user):
    self.id = id

    acl = self._getLDAPUserFolder(user)
    self._ldapschema = [(x['ldap_name'], x['public_name'],
                         'lines' if x['multivalued'] else 'string')
                        for x in acl.getSchemaConfig().values()
                        if x['public_name']]

    properties = self._getCache(user)
    if not isinstance(properties, dict):
        properties = self.fetchLdapProperties(user)
        if properties and isinstance(properties, dict):
            self._setCache(user, properties)

    if not isinstance(properties, dict):
        logger.warning(properties)
        properties = {}

    id = properties.pop('id', id)
    UserPropertySheet.__init__(self, id,
            schema=[(x[1], x[2]) for x in self._ldapschema], **properties)
Beispiel #8
0
def __patched_init__(self, id, user):
    self.id = id

    acl = self._getLDAPUserFolder(user)
    self._ldapschema = [(x['ldap_name'], x['public_name'],
                         'lines' if x['multivalued'] else 'string')
                        for x in acl.getSchemaConfig().values()
                        if x['public_name']]

    properties = self._getCache(user)
    if not isinstance(properties, dict):
        properties = self.fetchLdapProperties(user)
        if properties and isinstance(properties, dict):
            self._setCache(user, properties)

    if not isinstance(properties, dict):
        logger.warning(properties)
        properties = {}

    id = properties.pop('id', id)
    UserPropertySheet.__init__(self,
                               id,
                               schema=[(x[1], x[2]) for x in self._ldapschema],
                               **properties)
 def __init__(self, plugin, **kwargs):
     UserPropertySheet.__init__(self, plugin.id, **kwargs)
     self._plugin = plugin
Beispiel #10
0
 def __init__(self, plugin, **kwargs):
     UserPropertySheet.__init__(self, plugin.id, **kwargs)
     self._plugin = plugin