You are here

function ldapauth_update_6000 in LDAP integration 6

File

./ldapauth.install, line 231
ldapauth module installation and upgrade code.

Code

function ldapauth_update_6000() {
  $ret = array();
  $result = db_query("SELECT * FROM {ldapauth}");
  while ($row = db_fetch_object($result)) {
    $servers[$row->name] = $row->sid;
  }
  if (!empty($servers)) {
    $result = db_query("SELECT uid FROM {users} WHERE uid > '1'");
    while ($row = db_fetch_object($result)) {
      $account = user_load($row->uid);
      if ($account->ldap_config && in_array($account->ldap_config, array_keys($servers))) {
        user_save($account, array(
          'ldap_config' => $servers[$account->ldap_config],
        ));
      }
    }
  }
  return $ret;
}