Update user's name from ldap
775006
private function updateName()
    {
        if (!LOCAL) {
            $ds = ldap_connect("addressbook.ic.ac.uk");
            $r = ldap_bind($ds);
            $justthese = array("displayname");
            $sr = ldap_search(
                $ds,
                "ou=People,ou=shibboleth,dc=ic,dc=ac,dc=uk",
                "uid=".$this->getUser(),
                $justthese
            );
            $info = ldap_get_entries($ds, $sr);
            if ($info["count"] > 0) {
                $this->setName($info[0]['displayname'][0]);
                return ($info[0]['displayname'][0]);
            } else {
                return false;
            }
        } else {
            $name = $this->getName();
            return $name;
        }
    }
101699
private String updateAccount(Long userId) {
    String email = get("mail");
    String pwd = get("password");
    Map<String, Object> valueMap = CollectUtils.newHashMap();
    valueMap.put("password", pwd);
    valueMap.put("mail", email);
    entityDao.update(User.class, "id", new Object[] { userId }, valueMap);
    return redirect("infolet", "ok.passwordChanged", "&id=" + userId);
  }
899734
def update_identity(self):
        """"""

        fr = self.record

        d = fr.unpacked_contents

        d['identity'] = self._dataset.identity.ident_dict
        d['names'] = self._dataset.identity.names_dict

        fr.update_contents(msgpack.packb(d), 'application/msgpack')
921287
def set_user_name(self, uid, name):
        
        data = [uid]
        if len(name) > 16:
            raise Exception('name must be less than or = 16 chars')
        name = name.ljust(16, "\x00")
        data.extend([ord(x) for x in name])
        self.xraw_command(netfn=0x06, command=0x45, data=data)
        return True
515358
def direct_bind(self, username, password):
        
        log.debug("Performing direct bind")

        ctx = {'username':username, 'password':password}
        scope = self.config.get('SCOPE', ldap.SCOPE_SUBTREE)
        user = self.config['BIND_DN'] % ctx

        try:
            log.debug("Binding with the BIND_DN %s" % user)
            self.conn.simple_bind_s(user, password)
        except ldap.INVALID_CREDENTIALS:
            if self._raise_errors:
                raise ldap.INVALID_CREDENTIALS("Unable to do a direct bind with BIND_DN %s" % user)
            return None
        results = self.conn.search_s(user, scope, attrlist=self.attrlist)
        self.conn.unbind_s()
        return self.format_results(results)
288920
def change_name(self, username):
        
        self.release_name()

        try:
            self.server.register_name(username)
        except UsernameInUseException:
            logging.log(', '.join(self.server.registered_names))
            self.server.register_name(self.name)
            raise
            
        self.name = username
616740
public function userUsernameFromLdapEntry($ldap_entry) {


    if ($this->account_name_attr) {
      $accountname = (empty($ldap_entry[$this->account_name_attr][0])) ? FALSE : $ldap_entry[$this->account_name_attr][0];
    }
    elseif ($this->user_attr)  {
      $accountname = (empty($ldap_entry[$this->user_attr][0])) ? FALSE : $ldap_entry[$this->user_attr][0];
    }
    else {
      $accountname = FALSE;
    }

    return $accountname;
  }
1311256
def create(self, fname, lname, group, type, group_api):
        """"""
        self.__username(fname, lname)
        self.client.add(
            self.__distinguished_name(type, fname=fname, lname=lname),
            API.__object_class(),
            self.__ldap_attr(fname, lname, type, group, group_api))
973117
def cli(ctx, email, first_name, last_name, password, metadata={}):
    
    return ctx.gi.users.update_user(email, first_name, last_name, password, metadata=metadata)
188051
def get_keys_from_ldap(self, username=None):
        
        result_dict = {}
        filter = ['(sshPublicKey=*)']
        if username is not None:
            filter.append('(uid={})'.format(username))
        attributes = ['uid', 'sshPublicKey']
        results = self.client.search(filter, attributes)
        for result in results:
            result_dict[result.uid.value] = result.sshPublicKey.values
        return result_dict
380548
def _bind(self):
        """"""
        ldap_client = self._connect()
        try:
            ldap_client.simple_bind_s(self.binddn, self.bindpassword)
        except Exception as e:
            ldap_client.unbind_s()
            self._exception_handler(e)
        return ldap_client
1309980
def userinfo(self, username, realname=None):
        
        realname = realname or username

        _log.info("Requesting user info update: username=%s realname=%s",
            username, realname)

        self.send("USER", username, socket.getfqdn(), self.server.host,
            ":%s" % realname) # Realname should always be prefixed by a colon
        self.user.username = username
        self.user.realname = realname
366125
def _update_name(self):
        """"""
        self._name = self._json_state.get('name')
        if not self._name:
            self._name = self.type + ' ' + self.device_id
1344062
def set_name(self, name):
        """"""
        if not name:
            name = ''
        self._client['config']['name'] = name
        yield from self._server.client_name(self.identifier, name)
1168345
def bind(self):
        

        conn = self.initialize
        try:
            conn.simple_bind_s(
                current_app.config['LDAP_USERNAME'],
                current_app.config['LDAP_PASSWORD'])
            return conn
        except ldap.LDAPError as e:
            raise LDAPException(self.error(e.args))
899692
def modify_user(self, username, attribute, value):
        

        cmd = "userManager.cgi?action=modifyUser&name={0}".format(
            username)

        if attribute.lower() == "group":
            cmd += "&user.Group=%s" % value.lower()

        elif attribute.lower() == "sharable":
            cmd += "&user.Sharable=%s" % value.lower()

        elif attribute.lower() == "reserved":
            cmd += "&user.Reserved=%s" % value.lower()

        elif attribute == "memo":
            cmd += "&user.Memo=%s" % value.lower()

        ret = self.command(cmd)
        return ret.content.decode('utf-8')
1136545
def set_attrs(self, username, attrs):
        
        ldap_client = self._bind()
        tmp = self._get_user(self._byte_p2(username), ALL_ATTRS)
        if tmp is None:
            raise UserDoesntExist(username, self.backend_name)
        dn = self._byte_p2(tmp[0])
        old_attrs = tmp[1]
        for attr in attrs:
            bcontent = self._byte_p2(attrs[attr])
            battr = self._byte_p2(attr)
            new = {battr: self._modlist(self._byte_p3(bcontent))}
            # if attr is dn entry, use rename
            if attr.lower() == self.dn_user_attr.lower():
                ldap_client.rename_s(
                    dn,
                    ldap.dn.dn2str([[(battr, bcontent, 1)]])
                    )
                dn = ldap.dn.dn2str(
                    [[(battr, bcontent, 1)]] + ldap.dn.str2dn(dn)[1:]
                    )
            else:
                # if attr is already set, replace the value
                # (see dict old passed to modifyModlist)
                if attr in old_attrs:
                    if type(old_attrs[attr]) is list:
                        tmp = []
                        for value in old_attrs[attr]:
                            tmp.append(self._byte_p2(value))
                        bold_value = tmp
                    else:
                        bold_value = self._modlist(
                            self._byte_p3(old_attrs[attr])
                        )
                    old = {battr: bold_value}
                # attribute is not set, just add it
                else:
                    old = {}
                ldif = modlist.modifyModlist(old, new)
                if ldif:
                    try:
                        ldap_client.modify_s(dn, ldif)
                    except Exception as e:
                        ldap_client.unbind_s()
                        self._exception_handler(e)

        ldap_client.unbind_s()