Logo Search packages:      
Sourcecode: zope-ldapuserfolder version File versions

def LDAPUserFolder::LDAPUserFolder::LDAPUserFolder::manage_editUser (   self,
  user_dn,
  REQUEST = None,
  kwargs = {} 
)

Edit a user record 

Definition at line 1378 of file LDAPUserFolder.py.

01378                                                             {}):
        """ Edit a user record """
        msg = ''
        new_attrs = {}
        if REQUEST is None:
            source = kwargs
        else:
            source = REQUEST

        for attr in self.getSchemaConfig().keys():
            if source.has_key(attr):
                new = source.get(attr, '')
                if isinstance(new, StringType):
                    new = [x.strip() for x in new.split(';')]

                new_attrs[attr] = new

        if new_attrs:
            msg = self._delegate.modify(user_dn, attrs=new_attrs)
        else:
            msg = 'No attributes changed'

        if msg:
            if REQUEST:
                return self.manage_userrecords( manage_tabs_message=msg
                                              , user_dn=user_dn
                                              )
            else:
                return msg

        rdn = self._rdnattr
        new_cn = source.get(rdn, '')
        new_dn = ''
        old_dn_exploded = explode_dn(user_dn)
        cur_rdn = old_dn_exploded[0]
        cur_cn = cur_rdn.split('=')[1]

        if new_cn and cur_cn != new_cn:
            old_dn = user_dn
            old_dn_exploded[0] = '%s=%s' % (rdn, new_cn)
            new_dn = ','.join(old_dn_exploded)

            old_groups = self.getGroups(dn=old_dn, attr='dn')

            if self._local_groups:
                if self._groups_store.get(old_dn):
                    del self._groups_store[old_dn]

                self._groups_store[new_dn] = old_groups

            else:
                for group in old_groups:
                    group_type = self.getGroupType(group)
                    member_type = GROUP_MEMBER_MAP.get(group_type)

                    msg = self._delegate.modify( group
                                               , DELETE
                                               , {member_type : [old_dn]}
                                               )
                    msg = self._delegate.modify( group
                                               , ADD
                                               , {member_type : [new_dn]}
                                               )

        self._expireUser(cur_cn)
        msg = msg or 'User %s changed' % (new_dn or user_dn)

        if REQUEST:
            return self.manage_userrecords( manage_tabs_message=msg
                                          , user_dn=new_dn or user_dn
                                          )

    security.declareProtected(manage_users, '_expireUser')


Generated by  Doxygen 1.6.0   Back to index