You are here

function _ldapgroups_ldap_init in LDAP integration 6

Same name and namespace in other branches
  1. 5 ldapgroups.module \_ldapgroups_ldap_init()

Initiates the LDAPInterfase class.

Parameters

$sid: A server ID or user object.

2 calls to _ldapgroups_ldap_init()
ldapgroups_user_login in ./ldapgroups.inc
Implements hook_user() login operation.
ldapgroups_user_test_output in ./ldapgroups.admin.inc
Generate the test results for the user and ldap settings.

File

./ldapgroups.inc, line 297
ldapgroups include file.

Code

function _ldapgroups_ldap_init($sid) {
  global $_ldapgroups_ldap;
  if (!($sid = is_object($sid) ? isset($sid->ldap_config) ? $sid->ldap_config : NULL : $sid)) {
    return;
  }
  $server = ldapauth_server_load($sid);
  if (!empty($server) && $server->status == 1) {
    $_ldapgroups_ldap = new LDAPInterface();
    $_ldapgroups_ldap
      ->setOption('sid', $sid);
    $_ldapgroups_ldap
      ->setOption('name', $server->name);
    $_ldapgroups_ldap
      ->setOption('machine_name', $server->machine_name);
    $_ldapgroups_ldap
      ->setOption('server', $server->server);
    $_ldapgroups_ldap
      ->setOption('port', $server->port);
    $_ldapgroups_ldap
      ->setOption('tls', $server->tls);
    $_ldapgroups_ldap
      ->setOption('enc_type', $server->enc_type);
    $_ldapgroups_ldap
      ->setOption('basedn', $server->basedn);
    $_ldapgroups_ldap
      ->setOption('user_attr', $server->user_attr);
    $_ldapgroups_ldap
      ->setOption('binddn', $server->binddn);
    $_ldapgroups_ldap
      ->setOption('bindpw', $server->bindpw);
    return $_ldapgroups_ldap;
  }
}