$countries[$obj->rowid] = array('rowid' => $obj->rowid, 'label' => $obj->label, 'code' => $obj->code);
            }
            $i++;
        }
    }
} else {
    dol_print_error($db);
    exit(-1);
}
$ldap = new Ldap();
$result = $ldap->connect_bind();
if ($result >= 0) {
    $justthese = array();
    // We disable synchro Dolibarr-LDAP
    $conf->global->LDAP_MEMBER_ACTIVE = 0;
    $ldaprecords = $ldap->getRecords('*', $conf->global->LDAP_MEMBER_DN, $conf->global->LDAP_KEY_MEMBERS, $required_fields, 0);
    if (is_array($ldaprecords)) {
        $db->begin();
        // Warning $ldapuser has a key in lowercase
        foreach ($ldaprecords as $key => $ldapuser) {
            $member = new Adherent($db);
            // Propriete membre
            $member->firstname = $ldapuser[$conf->global->LDAP_FIELD_FIRSTNAME];
            $member->lastname = $ldapuser[$conf->global->LDAP_FIELD_NAME];
            $member->login = $ldapuser[$conf->global->LDAP_FIELD_LOGIN];
            $member->pass = $ldapuser[$conf->global->LDAP_FIELD_PASSWORD];
            //$member->societe;
            $member->address = $ldapuser[$conf->global->LDAP_FIELD_ADDRESS];
            $member->zip = $ldapuser[$conf->global->LDAP_FIELD_ZIP];
            $member->town = $ldapuser[$conf->global->LDAP_FIELD_TOWN];
            $member->country = $ldapuser[$conf->global->LDAP_FIELD_COUNTRY];
Пример #2
0
 print $langs->trans("CreateInternalUserDesc");
 print "<br>";
 print "<br>";
 if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') {
     /*
      * Affiche formulaire d'ajout d'un compte depuis LDAP
      * si on est en synchro LDAP vers Dolibarr
      */
     $ldap = new Ldap();
     $result = $ldap->connect_bind();
     if ($result >= 0) {
         $required_fields = array($conf->global->LDAP_KEY_USERS, $conf->global->LDAP_FIELD_FULLNAME, $conf->global->LDAP_FIELD_NAME, $conf->global->LDAP_FIELD_FIRSTNAME, $conf->global->LDAP_FIELD_LOGIN, $conf->global->LDAP_FIELD_LOGIN_SAMBA);
         // Remove from required_fields all entries not configured in LDAP (empty) and duplicated
         $required_fields = array_unique(array_values(array_filter($required_fields, "dolValidElement")));
         // Get from LDAP database an array of results
         $ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1);
         if (is_array($ldapusers)) {
             $liste = array();
             foreach ($ldapusers as $key => $ldapuser) {
                 // Define the label string for this user
                 $label = '';
                 foreach ($required_fields as $value) {
                     if ($value) {
                         $label .= $value . "=" . $ldapuser[$value] . " ";
                     }
                 }
                 $liste[$key] = $label;
             }
         } else {
             $message = '<div class="error">' . $ldap->error . '</div>';
         }
print "commitiferror=" . $forcecommit . "\n";
print "Mapped LDAP fields=" . join(',', $required_fields) . "\n";
print "\n";
print "Hit Enter to continue or CTRL+C to stop...\n";
$input = trim(fgets(STDIN));
if (empty($conf->global->LDAP_GROUP_DN)) {
    print $langs->trans("Error") . ': ' . $langs->trans("LDAP setup for groups not defined inside Dolibarr");
    exit(-1);
}
$ldap = new Ldap();
$result = $ldap->connect_bind();
if ($result >= 0) {
    $justthese = array();
    // We disable synchro Dolibarr-LDAP
    $conf->global->LDAP_SYNCHRO_ACTIVE = 0;
    $ldaprecords = $ldap->getRecords('*', $conf->global->LDAP_GROUP_DN, $conf->global->LDAP_KEY_GROUPS, $required_fields, 0, array($conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS));
    if (is_array($ldaprecords)) {
        $db->begin();
        // Warning $ldapuser has a key in lowercase
        foreach ($ldaprecords as $key => $ldapgroup) {
            $group = new UserGroup($db);
            $group->fetch('', $ldapgroup[$conf->global->LDAP_KEY_GROUPS]);
            $group->name = $ldapgroup[$conf->global->LDAP_GROUP_FIELD_FULLNAME];
            $group->nom = $group->name;
            // For backward compatibility
            $group->note = $ldapgroup[$conf->global->LDAP_GROUP_FIELD_DESCRIPTION];
            $group->entity = $conf->entity;
            //print_r($ldapgroup);
            if ($group->id > 0) {
                // Group update
                print $langs->transnoentities("GroupUpdate") . ' # ' . $key . ': name=' . $group->name;