function user_modify($username,$attributes){
        if ($username==NULL){ return ("Missing compulsory field [username]"); }
        if (array_key_exists("password",$attributes) && !$this->_use_ssl){ echo ("FATAL: SSL must be configured on your webserver and enabled in the class to set passwords."); exit(); }
        //if (array_key_exists("container",$attributes)){
            //if (!is_array($attributes["container"])){ return ("Container attribute must be an array."); }
            //$attributes["container"]=array_reverse($attributes["container"]);
        //}

        //find the dn of the user
        $user=$this->user_info($username,array("cn"));
        if ($user[0]["dn"]==NULL){ return (false); }
        $user_dn=$user[0]["dn"];

        //translate the update to the LDAP schema				
        $mod=$this->adldap_schema($attributes);
        if (!$mod){ return (false); }
        
        //set the account control attribute (only if specified)
        if (array_key_exists("enabled",$attributes)){
            if ($attributes["enabled"]){ $control_options=array("NORMAL_ACCOUNT"); }
            else { $control_options=array("NORMAL_ACCOUNT","ACCOUNTDISABLE"); }
            $mod["userAccountControl"][0]=$this->account_control($control_options);
        }

        //do the update
        $result=ldap_modify($this->_conn,$user_dn,$mod);
        if ($result==false){ return (false); }
        
        return (true);
    }
function user_modify($username,$attributes){
        if ($username==NULL){ return ("Missing compulsory field [username]"); }
        if (array_key_exists("password",$attributes) && !$this->_use_ssl){ echo ("FATAL: SSL must be configured on your webserver and enabled in the class to set passwords."); exit(); }
        //if (array_key_exists("container",$attributes)){
            //if (!is_array($attributes["container"])){ return ("Container attribute must be an array."); }
            //$attributes["container"]=array_reverse($attributes["container"]);
        //}

        //find the dn of the user
        $user=$this->user_info($username,array("cn"));
        if ($user[0]["dn"]==NULL){ return (false); }
        $user_dn=$user[0]["dn"];

        //translate the update to the LDAP schema				
        $mod=$this->adldap_schema($attributes);
        if (!$mod){ return (false); }
        
        //set the account control attribute (only if specified)
        if (array_key_exists("enabled",$attributes)){
            if ($attributes["enabled"]){ $control_options=array("NORMAL_ACCOUNT"); }
            else { $control_options=array("NORMAL_ACCOUNT","ACCOUNTDISABLE"); }
            $mod["userAccountControl"][0]=$this->account_control($control_options);
        }

        //do the update
        $result=ldap_modify($this->_conn,$user_dn,$mod);
        if ($result==false){ return (false); }
        
        return (true);
    }
function user_modify ( $ username , $ attributes ) { if ( $ username == NULL ) { return ( "Missing compulsory field [username]" ) ; } if ( array_key_exists ( "password" , $ attributes ) && ! $ this -> _use_ssl ) { echo ( "FATAL: SSL must be configured on your webserver and enabled in the class to set passwords." ) ; exit ( ) ; } //if (array_key_exists("container",$attributes)){ //if (!is_array($attributes["container"])){ return ("Container attribute must be an array."); } //$attributes["container"]=array_reverse($attributes["container"]); //} //find the dn of the user $ user = $ this -> user_info ( $ username , array ( "cn" ) ) ; if ( $ user [ 0 ] [ "dn" ] == NULL ) { return ( false ) ; } $ user_dn = $ user [ 0 ] [ "dn" ] ; //translate the update to the LDAP schema				 $ mod = $ this -> adldap_schema ( $ attributes ) ; if ( ! $ mod ) { return ( false ) ; } //set the account control attribute (only if specified) if ( array_key_exists ( "enabled" , $ attributes ) ) { if ( $ attributes [ "enabled" ] ) { $ control_options = array ( "NORMAL_ACCOUNT" ) ; } else { $ control_options = array ( "NORMAL_ACCOUNT" , "ACCOUNTDISABLE" ) ; } $ mod [ "userAccountControl" ] [ 0 ] = $ this -> account_control ( $ control_options ) ; } //do the update $ result = ldap_modify ( $ this -> _conn , $ user_dn , $ mod ) ; if ( $ result == false ) { return ( false ) ; } return ( true ) ; }
modify a user
modify a user