Page 1 of 1

Accessing email database from other application

Posted: Thu Mar 23, 2006 5:23 pm
by IT@ORinc.
I am wondering if it's possible to access all the email adress on the Scalix Server from another application. I would like to create a list on our Intranet of all the email adresses we have on the server. I'm using PHP with odbc support on a linux (slackware 10.2) platform.

thank you in advance.

Matthieu

Posted: Fri Mar 24, 2006 1:12 pm
by florian
Hi Mathieu,

odbc wouldn't really matter here as we don't put our stuff in sql databases - it's not the most efficient storage for our kind of data.

try an

Code: Select all

"omldapsearch -h localhost -p 389 -b o=Scalix '(objectClass=*)'


on your scalix server....so... by all means if it is your address book that you want to access, LDAP is the way to go. PHP has good support for LDAP access, I believe.

cheers,
F.

Posted: Tue Mar 28, 2006 7:51 am
by burhankhalid
Matthieu:

This should get you going. Disclaimer -- I am not a LDAP expert, so this might not be the most efficient way to get to this information. I was hacking away at getting a summary page to print all email addresses using PHP, and came up with this code to connect and get the email addresses.

Code: Select all

<?php
 
  $scalix_host = "localhost";
 
  $conn = ldap_connect($scalix_host);
  if (!$conn)
  {
     echo 'Could not connect to '.$scalix_host;
     die('ERR: CONNECT');
  }
 
  # Anonymous bind
  ldap_bind($conn);
 
  $dn = "o=Scalix";
  $mail_node = 'MY-COMPANY';

  $filter = '(|(objectClass=scalixPerson)(omMailnode='.$mail_node.'))';

  # Items you would like to pick out from the search query above
  $find = array('mail','rfc822Mailbox','omCn');

  $search_handle = ldap_search($conn,$dn,$filter,$find);
  $result = ldap_get_entries($conn,$search_handle);
 
  print_r($result);
?>