You are here

ldapauth.install in LDAP integration 5.2

Same filename and directory in other branches
  1. 5 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\t\t\t\tsid  int NOT NULL auto_increment,\n\t\t\t\tname varchar(255) NOT NULL default '',\n\t\t\t\tstatus int NOT NULL default '0',\n\t\t\t\tserver varchar(255) NOT NULL default '',\n\t\t\t\tport int(10) NOT NULL default '389',\n\t\t\t\ttls int NOT NULL default '0',\n\t\t\t\tencrypted int NOT NULL default '0',\n\t\t\t\tbasedn varchar(255) NOT NULL default '',\n\t\t\t\tuser_attr varchar(255) NOT NULL default '',\n\t\t\t\tbinddn varchar(255) NOT NULL default '',\n\t\t\t\tbindpw varchar(255) NOT NULL default '',\n\t\t\t\tbindpw_clear varchar(255) NOT NULL default '',\n\t\t\t\tldap_groups_in_dn int NOT NULL default '0',\n\t\t\t\tldap_groups_in_dn_desc int NOT NULL default '0',\n\t\t\t\tldap_group_dn_attribute varchar(255) default '',\n\t\t\t\tldap_group_attr varchar(255) default '',\n\t\t\t\tldap_groups_in_attr int NOT NULL default '0',\n\t\t\t\tldap_groups_as_entries int NOT NULL default '0',\n\t\t\t\tldap_group_entries varchar(255) default '',\n\t\t\t\tldap_group_entries_attribute varchar(255) default '',\n        PRIMARY KEY (name),\n        KEY sid (sid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      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_allow_request_new_password');
  variable_del('ldap_user_pass_form');
  variable_del('ldap_allow_user_reset_password');
}

/** 
 * Implementation of hook_update_N()
 */
function ldapauth_update_1() {
  $ret = array();
  if ($GLOBALS['db_type'] == 'mysql') {
    $ret[] = update_sql("ALTER TABLE {ldapauth} ADD ldapdata_binddn VARCHAR(255) NOT NULL default '' ");
    $ret[] = update_sql("ALTER TABLE {ldapauth} ADD ldapdata_bindpw VARCHAR(255) NOT NULL default '' ");
    $ret[] = update_sql("ALTER TABLE {ldapauth} ADD ldapdata_bindpw_clear VARCHAR(2) NOT NULL default '' ");
    $ret[] = update_sql("ALTER TABLE {ldapauth} ADD ldapdata_rwattrs LONGTEXT NOT NULL default '' ");
    $ret[] = update_sql("ALTER TABLE {ldapauth} ADD ldapdata_roattrs LONGTEXT NOT NULL default '' ");
    $ret[] = update_sql("ALTER TABLE {ldapauth} ADD ldapdata_mappings LONGTEXT NOT NULL default '' ");
  }
  return $ret;
}
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(1000) NOT NULL default '' ");
      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(1000) NOT NULL default '' ");
      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