RE: [PHP-WIN] LDAP and M$ Exchange 5.5 :: It's Not Happening.

From: Date: Wed, 23 May 2001 09:37:30 +0000
Subject: RE: [PHP-WIN] LDAP and M$ Exchange 5.5 :: It's Not Happening.
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-7866@lists.php.net to get a copy of this message
Sorry 4 my late answer, but I hadn't the time to view the list 4 the few last days =8( I have written some small applications with M$-Xchange and LDAP. You'll find a lot of examples and ready code (only ASP and VB) in the MSDN-CD's. You'll also need an Exchange-Account with the right privileges if you want more than only read from the LDAP-Server. I hope this helps. If you have more questions about Xchng && LDAP, ask me. I have also written a web-based ADSI-Browser in ASP (sorry, I was young and in need of the money =8) if you perhaps need it. But you can also use the Xchng-Server-Console (in admin-mode) to browse through the Xchng-Server, so that you will know where you will find the info needed. Greetinx, Mike Here is a small example I wrote (and the class): ---------snip------------ <?php ////////////////////////////////////////////////////////////////////////////////////////////// // <File-Header-Description> // ////////////////////////////////////////////////////////////////////////////////////////////// // // // Filename: LDAP_class_example.php // // // // Author: Michael Rudel [mru] - mailto:Michael-Rudel@gmx.de // // // ////////////////////////////////////////////////////////////////////////////////////////////// // // // Description: // // // // Usage: // // // // Notes: // // // // Bugs: // // // ////////////////////////////////////////////////////////////////////////////////////////////// // // History: 2000-10-23: mru: Created // ////////////////////////////////////////////////////////////////////////////////////////////// // </File-Header-Description> // ////////////////////////////////////////////////////////////////////////////////////////////// //Includes include( "LDAP_Functions.class" ); //Constants define( "BR", "<BR>\n" ); define( "NL", "\n" ); //Variables // $logon_user works only with NTML (MSIE, IIS) $logon_user = substr( str_replace( "\\", "/", $LOGON_USER ), ( strrpos( str_replace( "\\", "/", $LOGON_USER ), "//" ) + 1 ) ); $exchangeHost = "pcin39" $exchangePort = "" $exchangeUser = "" $exchangePasswort = "" $ldapBaseDN = "cn=Recipients, ou=PCIN-NET, o=in GmbH, c=de" //Objects $ldap = new ldap_handling; //Initialisation $ldap->developer = Administrator@yourcompany.com; $ldap->headers = $mailFrom."\nReply-To: ".$this->logon_user . "\nX-Mailer: PHP/".phpversion(); //Main // Connect to Exchange-Server $ldap->connect( $exchangeHost, $exchangePort, __FILE__, __LINE__ ); // Bind to open ldap_connect $ldap->bind( $exchangeUser, $exchangePasswort, __FILE__, __LINE__ ); // Searches through the recipients in the LDAP-Tree $ldap->search( $ldapBaseDN , "(&(objectClass=organizationalPerson)(!(department=Keine)))" , array( "uid", "cn", "mail", "telephonenumber", "dn" ) , __FILE__ , __LINE__ ); // Print out the result-array from the LDAP-Search print_array( $ldap->result_array ); // Close the LDAP-Connection to the Exchange-Server $ldap->close( __FILE__, __LINE__ ); //Functions // Prints out an array recursiv function print_array( $array, $seperator = "" ) { while ( list( $key, $val ) = each($array) ) { if ( is_array( $val ) ) { print_array( $val, $seperator." => ".$key ); } else { echo "$seperator => $key => $val".BR; } } echo BR; } //////////////// // local Vars: | // Tab-Width:3 | //-------------+ /////////////////////////// // End of File | // LDAP_class_example.php | //------------------------+ ?> ---------snip------------ And here my class the code uses: ---------snip------------ <?php ////////////////////////////////////////////////////////////////////////////////////////////// // <File-Header-Description> // ////////////////////////////////////////////////////////////////////////////////////////////// // // // Filename: LDAP_Functions.class // // // // Author: Michael Rudel [mru] - mailto: Michael-Rudel@gmx.de // // // ////////////////////////////////////////////////////////////////////////////////////////////// // // // Description: // // // // Usage: // // // // Notes: // // // // Bugs: // // // ////////////////////////////////////////////////////////////////////////////////////////////// // // History: 2000-09-23: mru: Created // 2000-10-26: mru: Added: ldap_search() function // ldap_close() function // (Host/User) in error() function (only with NTLM) // ////////////////////////////////////////////////////////////////////////////////////////////// // </File-Header-Description> // ////////////////////////////////////////////////////////////////////////////////////////////// // redeclaration protection if ( !defined( "__LDAP_HANDLING__" ) ) { define( "__LDAP_HANDLING__", 1 ); // $logon_user works only with NTML (MSIE, IIS) $logon_user = substr( str_replace( "\\", "/", $LOGON_USER ), ( strrpos( str_replace( "\\", "/", $LOGON_USER ), "//" ) + 1 ) ); $WWW_PATH = str_replace( strrchr( "http://".$SERVER_NAME.$SCRIPT_NAME, "/" ), "/", "http://".$SERVER_NAME.$SCRIPT_NAME ); class ldap_handling { var $ldap_connection; // Datenbase-Connection var $ldap_result; // Searchresult-Ressource var $ldap_host; // Host from LDAP-Servers var $ldap_port; // Port to LDAP-Servers var $developer; // Mailaddress of the responsible developer (for error mails) var $headers; // Additional Mail-Headers (From, Reply-To, X-Mailer, ...) var $redirection; // Bool-Flag whether to redirect in error-case or not (true/false) var $redirect; // Target-URL to redirect to in case of error var $result_array; // Searchresult-array // Constructor function ldap_handling() { // Initialize default-values $this->ldap_connection = 0; $this->ldap_binding = 0; $this->ldap_result = 0; $this->developer = "Administrator@nowhere.com"; $this->headers = "From: ERROR! Unknown-LDAP-Connection\nReply-To: ".$logon_user."\nX-Mailer: PHP/".phpversion(); $this->redirection = false; $this->redirect = "http://intra"; $this->result_array = ""; } // Connect to LDAP-Server function connect( $host="", $port="", $file="", $line="" ) // empty port defaults to port 389 { $this->ldap_host = $host; $this->ldap_port = $port; if ( !$this->ldap_connection = ldap_connect( $host, $port ) ) { $this->error( "ERROR: Connect to LDAP-Server [".$host."] on Port [".$port."] failed!", $file, $line ); } } // Binding to LDAP-Server function bind( $user="", $password="", $file="", $line="" ) // empty user and password try's to connect as anonymous to the LDAP-Server { if ( !$this->ldap_binding = ldap_bind( $this->ldap_connection, $user, $password ) ) { $this->error( "ERROR: Bind to LDAP-Server as User[".$user."] with Password [".$password."] failed!", $file, $line ); } } // Searches the LDAP-Tree function search( $base_dn = "", $filter = "", $arrayAttributes = array(), $file = "", $line = "" ) // whole LDAP-Directory if empty !! { // Filter-Syntax: string Filter [, array attributes [, int attrsonly [, int sizelimit [, int timelimit [, int deref]]]]] if ( !$this->ldap_result = ldap_search ( $this->ldap_connection, $base_dn, $filter, $arrayAttributes ) ) { $this->error( "ERROR: Searching LDAP-Server with base_dn[".$base_dn."] and filter[".$filter."] !", $file, $line ); } if ( !$this->result_array = ldap_get_entries( $this->ldap_connection, $this->ldap_result ) ) { $this->error( "ERROR: Getting the search-result entries from LDAP-Server with Search-Result-ID[".$this->ldap_result."] !", $file, $line ); } } // Closes the connection to LDAP-Server function close( $file="", $line="" ) { if ( !ldap_close( $this->ldap_connection ) ) { $this->error( "ERROR: Closing LDAP-Server [".$this->host."] on Port [".$this->port."] failed!", $file, $line ); } } // Returns LDAP-Errornumber function errno() { return ( ldap_errno( $this->ldap_connection ) ); } // returns LDAP-Errormessage function errmsg() { return ( ldap_error( $this->ldap_connection ) ); } // Errormessages are mailed to the responsible developer function error( $err_msg, $file, $line ) { global $logon_user; global $SERVER_NAME; // Constuct the errormessage $message = "PHP-ErrorMessage: ".$php_errormsg."\n"; $message .= "(".$SERVER_NAME."/".$logon_user.") LDAP-ERROR (".$this->errno()."): \"".$this->errmsg()."\"\n"; $message .= $err_msg."\nError located in file \"".$file."\"\non line (".$line.")"; // Send the errormessage to the developer error_log( $message, 1, $this->developer, $this->headers ); // Closes the LDAP-Connection if still open if ( $this->connection != Null ) { $this->close(); } // Redirects the user if $redirection isset to $redirect if ( $this->redirection ) { header( "Location: ".$this->redirect ); exit; } } } // END Class: ldap_handling } // END: Redeclare-Protection //////////////// // local Vars: | // Tab-Width:3 | //-------------+ ///////////////////////// // End of File | // LDAP_Functions.class | //----------------------+ ?>---------snip------------ > -----Original Message----- > From: Dickerson, Monty [mailto:webjavapro@integrity.tamu.edu] > Sent: Monday, May 21, 2001 9:21 PM > To: 'php-windows@lists.php.net' > Subject: [PHP-WIN] LDAP and M$ Exchange 5.5 :: It's Not Happening. > > > John, et.al., > > It appears that to do management of recipients on Exchange Server > will require using Microsoft COM and Microsoft ADSI; not just LDAP. > > Micro$oft embraced and extended LDAP, so that LDAP is a 2nd class > protocol that can't do everything. You have to do things the M$ > way on M$ products using M$ protocols. > > Freedom to "innovate." > > :( > > That's real interoperable, eh! > > > -/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/- > > > FROM: http://msdn.microsoft.com/library/psdk/adsi/ds2exchgd_9h84.htm > > Creating a Custom Recipient > > Dim strDisplayname As String > Dim strAlias As String > Dim strTelephone As String > Dim objCont As IADsContainer > Dim objNewCR As IADs > > strDisplayname = "James Smith" > strAlias = "jsmith" > strTelephone = "867-5309" > > Set objCont = > GetObject("LDAP://Server/cn=Recipients,ou=Site,o=Org") > Set objNewCR = objCont.Create("Remote-Address", CStr("cn=" & > stralias)) > objNewCR.Put "cn", CStr(strdisplayname) > objNewCR.Put "uid", CStr(stralias) > objNewCR.Put "telephoneNumber", CStr(strtelephone) > objNewCR.Put "Target-Address", "SMTP:jsmith@microsoft.com" > objNewCR.SetInfo > > Note: This example is specific to Exchange Server version 5.5 and > earlier, and is not upwardly compatible with Exchange 6.0. Management > and access of Exchange 6.0 Servers should be made through the > CDOEXM interfaces instead. > > -/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/- > > > -----Original Message----- > Sent: Monday, May 21, 2001 12:26 PM > To: php-windows@lists.php.net > Cc: 'JayAchTee'; 'oifik@odra.fr' > Subject: LDAP and M$ Exchange 5.5 > > Thanks for this tip! I ran some queries on > the Microsoft Support Knowledge Base for > Exchange 5.5, but found NO information or > examples of how to use LDAP with Exchange to > do what you say. > > Would you point me to a URL, or what keywords > to search on, or towards some resources which > provide more information - regarding this? > i.e. how to use LDAP to manage recipients on > the Exchange server.. > > sinc, > md > > > -----Original Message----- > > From: JayAchTee [mailto:john.thompson@odnss.com] > > Sent: Monday, May 21, 2001 7:01 AM > > To: php-windows@lists.php.net > > Subject: Re: [PHP-WIN] Exchange > > > > > > If you are running Exchange Server 5.5 SP 3+, then you can > use LDAP to > > manage recipients on the Exchange server. The Microsoft > > knowledge base has > > several examples of how to use LDAP with Exchange. > > > > Regards. > > > > ""oifik"" <oifik@odra.fr> wrote in message > > news:KAEPJALOADDAHFIAACFBGEFGCAAA.oifik@odra.fr... > > > I would like to know if with php we can manage exchange > > server (create > > > account...) by using the imap librairies and if yes > > > how we can doing it ? > > > I can connect to my server (pop or imap), i can check mail > > but it's all. > > > Tahnks and sor for my english. > > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net > For additional commands, e-mail: php-windows-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net >

« previous php.windows (#7866) next »