You are here

function ldapauth_update_6006 in LDAP integration 6

File

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

Code

function ldapauth_update_6006() {
  $ret = array();
  if (!db_column_exists('ldapauth', 'puid_attr')) {
    db_add_field($ret, 'ldapauth', 'puid_attr', array(
      'type' => 'varchar',
      'length' => 255,
    ));
  }
  if (!db_column_exists('ldapauth', 'binary_puid')) {
    db_add_field($ret, 'ldapauth', 'binary_puid', array(
      'type' => 'int',
      'size' => 'tiny',
      'default' => '0',
    ));
  }

  // Initial ldapauth_users definition
  if (db_table_exists('ldapauth_users')) {

    // Update being re-run.
    return $ret;
  }
  if ($GLOBALS['db_type'] == 'pgsql') {
    $puid_unique_fields = array(
      'puid',
    );
  }
  else {
    $puid_unique_fields = array(
      array(
        'puid',
        255,
      ),
    );

    // MySQL limit
  }
  $table = array(
    'description' => 'Stores information about ldap authenticated users.',
    'fields' => array(
      'luid' => array(
        'description' => 'Primary key: ldapauth users id',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'uid' => array(
        'description' => '{users}.uid',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'sid' => array(
        'description' => '{ldapauth}.sid used for authentication',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
      ),
      'machine_name' => array(
        'description' => '{ldapauth}.machine_name for cross server id',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'dn' => array(
        'description' => 'LDAP dn user was authenticated with',
        'type' => 'text',
        'not null' => TRUE,
      ),
      'puid' => array(
        'description' => 'Persistent and Unique User ID value for this user',
        'type' => 'text',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'luid',
    ),
    'unique keys' => array(
      'uid' => array(
        'uid',
      ),
      'puid_uniq' => $puid_unique_fields,
    ),
    'indexes' => array(
      'puid_idx' => array(
        array(
          'puid',
          255,
        ),
      ),
    ),
  );
  db_create_table($ret, 'ldapauth_users', $table);
  return $ret;
}