I added some code to allow for trust setups and to generally derive the basedn and domain controllers.
This works for my trust setup by leaving the basedn and domain controllers values blank in the admin module.
Original code:
$this->_log(ADI_LOG_NOTICE,'username: '.$username);
$this->_log(ADI_LOG_NOTICE,'password: **not shown**');
// Log informations
$this->_log(ADI_LOG_INFO,"Options for adLDAP connection:\n".
"- account_suffix: $this->_account_suffix\n".
"- base_dn: $this->_base_dn\n".
"- domain_controllers: $this->_domain_controllers\n".
"- ad_port: $this->_port\n".
"- use_tls: ".(int) $this->_use_tls."\n".
"- network timeout: ". $this->_network_timeout);
Modified code:
$this->_log(ADI_LOG_NOTICE,'username: '.$username);
$this->_log(ADI_LOG_NOTICE,'password: **not shown**');
$this->_log(ADI_LOG_NOTICE,'basedn: '.$this->_base_dn);
// If account suffix has domain and _base_dn is blank then
// set the _base_dn using the domain information in account suffix
if (strpos($this->_account_suffix,'@') !== false && $this->_base_dn == '' && strpos($this->_account_suffix,'.') !== false) {
$parts = explode('@',$this->_account_suffix);
$parts = explode('.',$parts[1]);
$this->_base_dn = 'DC='.$parts[0].',DC='.$parts[1];
$this->_log(ADI_LOG_INFO,"Derived _base_dn - ".$this->_base_dn);
}
// If domain controllers is blank then assume it is
// a trust setup and use account suffix as DC
if ($this->_domain_controllers == '') {
$this->_domain_controllers = str_replace('@','',$this->_account_suffix);
$this->_log(ADI_LOG_INFO,"Derived _domain_controllers ".$this->_domain_controllers);
}
// Log informations
$this->_log(ADI_LOG_INFO,"Options for adLDAP connection:\n".
"- account_suffix: $this->_account_suffix\n".
"- base_dn: $this->_base_dn\n".
"- domain_controllers: $this->_domain_controllers\n".
"- ad_port: $this->_port\n".
"- use_tls: ".(int) $this->_use_tls."\n".
"- network timeout: ". $this->_network_timeout);