Hi,

I make a simple patch for postaci's getMailAdress function. I think if we
work on postaci a little time, it can be more suitable for
qmail+ldap+courier imap+qpop3d. Attached patch just make the postaci
working with ldap. For performance reasons some database tables of
postaci can be re-arranged, and also some pieces of code can be
changed. I'll send a big patch if I find free time for this.

Murat Demirten <[EMAIL PROTECTED]>
Fingerprint: 1198 B162 75C9 9378 DABB BF08 E717 CE7D B5EE C7E4
<-- The biggest still the best, http://www.debian.org -->
diff --unified --recursive --new-file postaci/includes/functions.inc 
postaci-ldap/includes/functions.inc
--- postaci/includes/functions.inc      Mon Apr 23 10:29:55 2001
+++ postaci-ldap/includes/functions.inc Mon Apr 23 10:38:35 2001
@@ -13,22 +13,30 @@
     function getMailAdress($user_id) {

       global $db,$qmail_support;

 

-      $dbq = $db->execute("select username,domain_id,real_name from tblUsers where 
user_id=$user_id");

+      $dbq = $db->execute("select username from tblUsers where user_id=$user_id");

       $username = $dbq->fields['username'];

-      $domain_id = $dbq->fields['domain_id'];

-      $real_name = $dbq->fields['real_name'];

       $dbq->close();

-      $dbq = $db->execute("select domain from tblDomains where 
domain_id=$domain_id");

-      $domain = $dbq->fields['domain'];

-      $dbq->close();

-

-      if (!$qmail_support){

-        $mailadress = trim($username . "@" . $domain);

-      } else {

-        $mailadress = trim($username);

-      }

-

-      if (trim($real_name) != "") {

+       $ds = ldap_connect("localhost");

+       if ($ds) {

+               $bind = ldap_bind($ds);

+               $result = ldap_search($ds,"ou=accounts, dc=onar", "uid=$username");

+               // burada birden fazla kayit donmesini kontrol et

+               $info = ldap_get_entries($ds, $result);

+               if ($info["count"] > 0) {

+                       $mailadress = $info[0]["mail"][0];

+                       $real_name = $info[0]["cn"][0];

+                       } else {

+                       $dbq = $db->execute("select domain from tblDomains where 
+domain_id=1");

+                       // domain_id = 1 must be returned default domain

+                       $domain = $dbq->fields['domain'];

+                       $dbq->close();

+                       $mailadress = trim($username . "@" . $domain);

+                       }

+               } else {

+               echo "Can't connect ldap server !!!";

+               }

+       ldap_close($ds);

+       if (trim($real_name) != "") {

         $mailadress = $real_name . " <" . $mailadress . ">";

       }

 

Reply via email to