From 9abcb6a232dca13a4d8bfc1c839601f8d6c6bd23 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Thu, 23 Jun 2011 17:39:06 -0400 Subject: [PATCH] Mirror create_user methods --- ad-integration.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ad-integration.php b/ad-integration.php index 80e7a4f..6a7b462 100644 --- a/ad-integration.php +++ b/ad-integration.php @@ -58,7 +58,6 @@ public function create_user( $username, $userinfo = false, $display_name = false } - return $this->_create_user( $username, $userinfo[0], false, false, false, true ); } } @@ -72,13 +71,14 @@ public function create_user( $username, $userinfo = false, $display_name = false // Connect to Active Directory try { - $this->_adldap = @new adLDAP( array( + $this->_adldap = @new SIU_adLDAP( array( "base_dn" => $this->_base_dn, "domain_controllers" => explode(';', $this->_domain_controllers), "ad_port" => $this->_port, // AD port "use_tls" => $this->_use_tls, // secure? "network_timeout" => $this->_network_timeout, // network timeout - 'ad_username' => $ad_settings['username'], 'ad_password' => $ad_settings['password'] + "ad_username" => $ad_settings['username'], + "ad_password" => $ad_settings['password'] ) ); } catch (Exception $e) { $this->_log(ADI_LOG_ERROR,'adLDAP exception: ' . $e->getMessage()); @@ -91,8 +91,16 @@ public function create_user( $username, $userinfo = false, $display_name = false $account_suffix = trim($account_suffix); $this->_log(ADI_LOG_NOTICE,'trying account suffix "'.$account_suffix.'"'); $this->_adldap->set_account_suffix($account_suffix); - - $userinfo = $this->_adldap->user_info($username, $this->_all_user_attributes); + + // Find user by email address + $un = $this->_adldap->find_user_by_email( $username ); + + if ( empty( $un ) ) + return false; + + // Get all userdata + $userinfo = $this->_adldap->user_info( $un[0], $this->_all_user_attributes ); + } return $this->_create_user( $username, $userinfo[0], false, false, false, true );