You are here

ldapauth.install in LDAP integration 5

Same filename and directory in other branches
  1. 5.2 ldapauth.install
  2. 6 ldapauth.install

File

ldapauth.install
View source
<?php

/**
 * Implementation of hook_install().
 */
function ldapauth_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {ldapauth} (\n        sid int NOT NULL auto_increment,\n        name varchar(255) NOT NULL default '',\n        status int NOT NULL default '0',\n        server varchar(255) NOT NULL default '',\n        port int(10) NOT NULL default '389',\n        tls int NOT NULL default '0',\n        encrypted int NOT NULL default '0',\n        basedn text NOT NULL,\n        user_attr varchar(255) NOT NULL default '',\n        mail_attr VARCHAR(255) NOT NULL DEFAULT '',\n        binddn varchar(255) NOT NULL default '',\n        bindpw varchar(255) NOT NULL default '',\n        bindpw_clear varchar(255) NOT NULL default '',\n        PRIMARY KEY (name),\n        KEY sid (sid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {ldapauth} (\n        sid SERIAL,\n        name VARCHAR(255) NOT NULL DEFAULT '',\n        status INTEGER NOT NULL DEFAULT 0,\n        server VARCHAR(255) NOT NULL DEFAULT '',\n        port INTEGER NOT NULL DEFAULT 389,\n        tls INTEGER NOT NULL DEFAULT 0,\n        encrypted INTEGER NOT NULL DEFAULT 0,\n        basedn text NOT NULL,\n        user_attr VARCHAR(255) NOT NULL DEFAULT '',\n        mail_attr VARCHAR(255) NOT NULL DEFAULT '',\n        binddn VARCHAR(255) NOT NULL DEFAULT '',\n        bindpw VARCHAR(255) NOT NULL DEFAULT '',\n        bindpw_clear VARCHAR(255) NOT NULL DEFAULT '',\n        PRIMARY KEY (name)\n      )");
      db_query("CREATE INDEX {ldapauth}_sid_idx ON {ldapauth} (sid)");
      break;
  }
}

/**
 * Implementation of hook_uninstall().
 */
function ldapauth_uninstall() {
  db_query('DROP TABLE {ldapauth}');
  variable_del('ldap_forget_passwords');
  variable_del('ldap_login_process');
  variable_del('ldap_disable_request_new_password');
  variable_del('ldap_alter_reset_form');
  variable_del('ldap_alter_email_field');
  variable_del('ldap_user_pass_form');
  variable_del('ldap_disable_user_request_password');
  variable_del('ldap_forget_passwords');
  variable_del('ldap_login_process');
}

/**
 * Implementation of hook_update_N()
 */
function ldapauth_update_1() {

  /* update removed to ldapdata.install */
}
function ldapauth_update_2() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {ldapauth} ADD mail_attr VARCHAR(255) NOT NULL default '' AFTER user_attr ");
      $ret[] = update_sql("ALTER TABLE {ldapauth} MODIFY basedn TEXT NOT NULL ");
      break;
    case 'pgsql':
      $ret[] = update_sql("ALTER TABLE {ldapauth} ADD mail_attr VARCHAR(255) NOT NULL default '' AFTER user_attr ");
      $ret[] = update_sql("ALTER TABLE {ldapauth} MODIFY basedn TEXT NOT NULL ");
      break;
  }
  return $ret;
}

Functions

Namesort descending Description
ldapauth_install Implementation of hook_install().
ldapauth_uninstall Implementation of hook_uninstall().
ldapauth_update_1 Implementation of hook_update_N()
ldapauth_update_2