Exemple #1
0
            define('LDAP_LAYER', 'LDAP2');
        } else {
            define('LDAP_LAYER', 'LDAP');
        }
    }
}
if (LDAP_LAYER == 'LDAP2') {
    if (!@(include_once 'Net/LDAP2.php')) {
        print 'skip could not find Net/LDAP2.php';
        exit;
    } else {
        include_once dirname(dirname(__FILE__)) . '/settings.php';
        $ldap = Net_LDAP2::connect($ldapConfig);
        if (PEAR::isError($ldap)) {
            print 'skip could not connect to LDAP directory';
            exit;
        }
    }
} else {
    if (!@(include_once 'Net/LDAP.php')) {
        print 'skip could not find Net/LDAP.php';
        exit;
    } else {
        include_once dirname(dirname(__FILE__)) . '/settings.php';
        $ldap = Net_LDAP::connect($ldapConfig);
        if (PEAR::isError($ldap)) {
            print 'skip could not connect to LDAP directory';
            exit;
        }
    }
}
Exemple #2
0
<?php

require_once '../../../../config/dmsDefaults.php';
require_once KT_LIB_DIR . '/authentication/authenticationutil.inc.php';
require_once KT_LIB_DIR . '/authentication/authenticationsource.inc.php';
require_once 'Net/LDAP.php';
$oKTConfig =& KTConfig::getSingleton();
$oAuthenticator = KTAuthenticationUtil::getAuthenticatorForSource(2);
$config = array('dn' => $oAuthenticator->sSearchUser, 'password' => $oAuthenticator->sSearchPassword, 'host' => $oAuthenticator->sLdapServer, 'base' => $oAuthenticator->sBaseDN);
$oLdap =& Net_LDAP::connect($config);
if (PEAR::isError($oLdap)) {
    var_dump($oLdap);
    exit(0);
}
$aParams = array('scope' => 'sub', 'attributes' => array('cn', 'dn', 'displayClass'));
$rootDn = $oAuthenticator->sBaseDN;
if (is_array($rootDn)) {
    $rootDn = join(",", $rootDn);
}
$oResults = $oLdap->search($rootDn, '(objectClass=group)', $aParams);
foreach ($oResults->entries() as $oEntry) {
    var_dump($oEntry->dn());
}
 function checkSignupPassword($sUsername, $sPassword)
 {
     $aUsers = $this->findUser($sUsername);
     if (empty($aUsers)) {
         return false;
     }
     if (count($aUsers) !== 1) {
         return false;
     }
     $dn = $aUsers[0]['dn'];
     $config = array('host' => $this->sLdapServer, 'base' => $this->sBaseDN, 'tls' => $this->bTls, 'port' => $this->iLdapPort);
     $oLdap =& Net_LDAP::connect($config);
     if (PEAR::isError($oLdap)) {
         return $oLdap;
     }
     $res = $oLdap->reBind($dn, $sPassword);
     if ($res === true) {
         return $dn;
     }
     return $res;
 }
Exemple #4
0
 /**
  * Establishes datasource connections settings
  *
  * @return  boolean     success
  */
 public function setConnection()
 {
     // Inclusion of the Net_LDAP package:
     require_once 'Net/LDAP.php';
     // The configuration array:
     $config = array('binddn' => $this->params['binddn'], 'bindpw' => $this->params['bindpw'], 'basedn' => $this->params['basedn'], 'host' => $this->params['hostname']);
     // Connecting using the configuration:
     $this->ldap = Net_LDAP::connect($config);
     // Testing for connection error
     if (PEAR::isError($ldap)) {
         die('Could not connect to LDAP-server: ' . $ldap->getMessage());
     }
 }