예제 #1
0
파일: users.py 프로젝트: seryl/Nodetraq
    def update(self, account):
        update_items = (
            'cn', 'uidNumber', 'mail',
            'loginShell', 'title', 'manager',
            'departmentNumber', 'roomNumber',
            'deploycode', 'orgchartmanager', 'utilityaccount')

        dh = DirectoryHelper(
            directoryCN, directoryPassword, directoryDomain)

        updates = {}
        groups = [v for k,v in request.params.items() if k == 'group']
        for item in update_items:
            if item in request.params:
                if item == 'cn':
                    updates['cn'] = request.params[item]
                    updates['gecos'] = request.params[item]
                    splitname = request.params[item].split()
                    updates['givenName'] = splitname[0]
                    if len(splitname) > 1:
                        updates['sn'] = splitname[1]
                updates[item] = request.params[item]

        # for key in updates, update ldap and ad
        for k, v in updates.iteritems():
            dh.update_attribute(account, k, v)
        # for group in groups, update ldap groups
        dh.set_groups(account, groups)

        session['flash'] = 'Successfully updated %s' % account
        session.save()

        updates['account'] = account
        ae = ActivityEngine(Session, session['active_user']['user_id'])
        ae.update('user', None, updates)

        return redirect(url(controller='users', action='edit', account=account))