List Info

Thread: Re: Maia authenticating against Exchange 2007?




Re: Maia authenticating against Exchange 2007?
country flaguser name
United States
2008-02-26 09:36:44

I use the LDAP login method and have modified it to work better with AD. Basically I use the username/password from the person attempting to login to bind to the AD and do a query, if all that works then the user is valid in AD and therefore valid to login. Below is my modifications to the auth_ldap function. The AD query I set in config.php is $auth_ldap_query = "( userprincipalname=%25%25USER%25%25DOMAIN.NAME">userprincipalname=%%USER%%DOMAIN.NAME)"; Obviously change all DOMAIN.NAME to your domain name.

 

    /*

     * auth_ldap(): Authenticate against an LDAP server.

 &nbsp; &nbsp; * &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; Code contributed by David Morton <osprey.net">mortondaosprey.net>.

 &nbsp; &nbsp; * Modified by: Tad DeVries <gmail.com">taddevriesgmail.com> on 01/28/2008

 &nbsp; &nbsp; */

 &nbsp;  function auth_ldap($user, $pass)

 &nbsp;  {

 &nbsp; &nbsp; &nbsp; if ($user == "&quot;) {  // Don't bother authenticating an empty username

 &nbsp; &nbsp; &nbsp;  return false;&nbsp; &nbsp; &nbsp; // ticket #335

 &nbsp; &nbsp; &nbsp; }

 &nbsp; &nbsp; &nbsp;  global $dbh;

 &nbsp; &nbsp; &nbsp;  global $lang;

 &nbsp; &nbsp; &nbsp;  global $auth_ldap_server;

 &nbsp; &nbsp; &nbsp;  global $auth_ldap_bind_dn;

 &nbsp; &nbsp; &nbsp;  global $auth_ldap_base_dn;

 &nbsp; &nbsp; &nbsp;  global $auth_ldap_password;

 &nbsp; &nbsp; &nbsp;  global $auth_ldap_query;

 &nbsp; &nbsp; &nbsp;  global $auth_ldap_attribute;

 &nbsp; &nbsp; &nbsp;  global $auth_ldap_version;

 &nbsp; &nbsp; &nbsp;  global $auth_ldap_opt_referrals;

 

 &nbsp; &nbsp; &nbsp;  $ldap_conn = ldap_connect($auth_ldap_server)

   &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; or die($lang['error_ldap_connect']);

 

 &nbsp; &nbsp; &nbsp;  if(isset($auth_ldap_version)) {

 &nbsp; &nbsp; &nbsp; &nbsp;  ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, $auth_ldap_version);

 &nbsp; &nbsp; &nbsp;  }

 

 &nbsp; &nbsp; &nbsp;  if(isset($auth_ldap_opt_referrals)) {

 &nbsp; &nbsp; &nbsp; &nbsp;  ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, $auth_ldap_opt_referrals);

 &nbsp; &nbsp; &nbsp;  }

 

 &nbsp; &nbsp; &nbsp;  if( ldap_bind($ldap_conn, $user.&quot;DOMAIN.NAME", $pass) )

 &nbsp; &nbsp; &nbsp;  {

 &nbsp; &nbsp; &nbsp; &nbsp;   ; //at this point the user is already verified

 &nbsp; &nbsp; &nbsp; &nbsp;   ; //but I'm paranoid so I do a query to make sure

 &nbsp; &nbsp; &nbsp; &nbsp;   ; $filter = $auth_ldap_query;

 &nbsp; &nbsp; &nbsp; &nbsp;   ; $filter = str_replace("%%USER%%", $user, $filter);

 

 &nbsp; &nbsp; &nbsp; &nbsp;   ; $sr = ldap_search($ldap_conn, $auth_ldap_base_dn, $filter,

 &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;  &nbsp; &nbsp; &nbsp;array($auth_ldap_attribute, "dn&quot;));

 

 &nbsp; &nbsp; &nbsp; &nbsp;   ; if( ldap_count_entries( $ldap_conn, $sr ) == 1 )

 &nbsp; &nbsp; &nbsp; &nbsp;   ; { // found user

 &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; $entries = ldap_get_entries( $ldap_conn, $sr );

 &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; $userdn = $entries["0&quot;][";dn"];

 &nbsp; &nbsp; &nbsp; &nbsp;   ;   &nbsp; $routingaddress = $entries["0&quot;][";$auth_ldap_attribute&quot;][&quot;0"];

 

 &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; ldap_close( $ldap_conn );

 &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; return $routingaddress;

 &nbsp; &nbsp; &nbsp; &nbsp;   ; } else {

 &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; ldap_close( $ldap_conn );

 &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; return false;

 &nbsp; &nbsp; &nbsp; &nbsp;   ; }

 &nbsp; &nbsp; &nbsp;  } else { // could not bind, user/pass not valid

 &nbsp; &nbsp; &nbsp; &nbsp;   ; ldap_close($ldap_conn);

 &nbsp; &nbsp; &nbsp; &nbsp;   ; return false;

 &nbsp; &nbsp; &nbsp;  }

 &nbsp;  }

 

-----Original Message-----

From: maia-users-bouncesrenaissoft.com [mailto:maia-users-bouncesrenaissoft.com] On Behalf Of Dirk Bonengel

Sent: Monday, February 25, 2008 22:41

To: maia-usersrenaissoft.com

Subject: [Maia-users] Maia authenticating against Exchange 2007?

 

Hi, all,

 

I try to set up a Maia Mailguard box (more precise: Maia's web

interface)  to authenticate against a Server running M$ Exchange 2007.

There must have been changes here compared to Exchange 2003 as I can't get the 'exchange' method to work (or I do things fundamentally wrong).

Anyone on the list having experience with this?

 

Thanks in advance

 

Dirk

_______________________________________________

Maia-users mailing list

Maia-usersrenaissoft.com">Maia-usersrenaissoft.com

http://www.renaissoft.com/mailman/listinfo/maia-users

 

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )