Example #1
0
        if ($_REQUEST['username']) {
            $search = "username="******"username", "*", false, "db");
        $items_count = count($allItems);
        if ($_REQUEST['username']) {
            $Message = "Updating Ldap user from the Database: " . $_REQUEST['username'] . "<br/>";
        } else {
            $Message = "Updating Ldap users from the Database ({$items_count} items)...<br/>";
        }
        $errors = 0;
        foreach ($allItems as $item) {
            $opUser = new User();
            // create empty user to write the data
            if ($opUser->updateFromArray($item)) {
                if ($opUser->createLdap()) {
                    $Message .= "Created/Updated user in LDAP: {$opUser->username} <br/>";
                } else {
                    $Message .= "<strong>Failed to update ldap user: "******"{$item['username']}: {$opUser->Message} </strong><br/>";
                    //echo "<pre>",print_r($opUser->toArray()),"</pre><br/>";
                    $errors++;
                }
            } else {
                $Message .= "<strong>Failed to update user from array: {$item['username']} </strong><br/>";
                $errors++;
            }
        }
        $Message .= "Ldap updating Complete! {$errors} errors.<br/><br/>";
    }
}
?>