[PHP] LDAP problems

2003-06-12 Thread Praveen Kumar

Dear Walker,
After connecting to the LDAP using ldap_connect('localhost'); you should
use ldap_bind like the code given below.

?php
$conn = ldap_connect(localhost) or die(Could not connect to server.
Error is  . ldap_error($conn)); 
// bind to the LDAP server 
$r = ldap_bind($conn, $root_dn, $root_pw) or die(Could not bind to
server. Error is  . ldap_error($conn));

$dn = dc=softprosys,dc=com;
$filter = cn=.$dname.*;
$sr=ldap_search($conn,$dn,$filter,$justthese);  

?

Hope this should help.
Regards
Praveen

---SOFTPRO DISCLAIMER--

Information contained in this E-MAIL and any attachments are
confidential being  proprietary to SOFTPRO SYSTEMS  is 'privileged'
and 'confidential'.

If you are not an intended or authorised recipient of this E-MAIL or
have received it in error, You are notified that any use, copyiny or
dissemination  of the information contained in this E-MAIL in any
manner whatsoever is strictly prohibited. Please delete it immediately
and notify the sender by E-MAIL.

In such a case reading, reproducing, printing or further dissemination
of this E-MAIL is strictly prohibited and may be unlawful.

SOFTPRO SYSYTEMS does not REPRESENT or WARRANT that an attachment
hereto is free from computer viruses or other defects. 

The opinions expressed in this E-MAIL and any ATTACHEMENTS may be
those of the author and are not necessarily those of SOFTPRO SYSTEMS.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] LDAP problems

2003-06-11 Thread Caleb Walker
Can anyone tell me what is wrong with this simple code?  It errors with
the ldap_get_values and says: supplied resource is not a valid ldap
result entry resource

I am very new at PHP LDAP so pardon my error...

?
//include inc/connect.inc.php;
$ds = ldap_connect(localhost);
$base = ou=people,dc=cwalk,dc=org;
$filter = ((givenname=$givenName*)(sn=$sn*));
$search = ldap_list($ds, $base, $filter);
$mail = mail;
$attrs = ldap_get_values($ds, $search, $mail);
?


-- 
Caleb Walker CCSE, MCSE



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] LDAP problems Apache 1.3.22 PHP 4.2.1

2002-05-29 Thread Oakes, Edward B


I am having problems with Apache occasionally giving me a
segmentation fault when making ldap calls from php.

I am currently using openldap-2.0.23, Apache 1.3.22 and
PHP 4.2.1.

My php program is being used to authenticate a user against
several Microsoft Active Directory Servers.  It works 
flawlessly 95% of the time, but intermittently (about 5%
of the time) Apache gives me a segmentation faulty 
when I call I get either ldap_bind or ldap_close.

My code basically:

Opens a socket to port 389 to be sure the server is working.
Close the socket
If the server is operational use ldap_connect to connect to the server
Use ldap_bind to bind to the server as a known user.
Do an ldap_search for the cn and sn of the user we want to
authenticate.
Use ldap_get_entries to put the returned entries into a string.
   
At this point the next ldap call I make sometimes causes a
segmentation fault but most of the time it works.  At this 
point what I need to do is do a ldap_bind as the correct user
to authenticate them.  If I try either an ldap_unbind, ldap_close,
or ldap_bind here all of these will work most of the time and give me
a segmentation fault occasionally.
 
Here is the basic php code.

  // Check to see that the active directory server is operational
  // before we try to make a connection to it.
  if ($fp = fsockopen($ADServer1,389,$errno,$errstr,$Timeout)) {
fclose($fp);
$ds=ldap_connect($ADServer1);
$ADServer=$ADServer1;
  }
  if (!$ds) {
 if ($fp = fsockopen($ADServer2,389,$errno,$errstr,$Timeout)) {
   fclose($fp);
   $ds=ldap_connect($ADServer2);
   $ADServer=$ADServer2;
 }
  }
  if (!$ds) {
 DisplayError(Unable to bind to ldap server);
 exit;
  } else {
 //
 // First bind as our ANONYMOUS user and lookup the full cn
 // for the user that is actually logging in.
 //
 if (!(ldap_bind($ds,$LOOKUP_BIND_DN,$LOOKUP_BIND_PASSWORD))) {
   DisplayError(LDAP Bind for $LOOKUP_BIND_USER did not work);
   ldap_unbind($ds);
   exit;
 } else {
   $justthese=array(cn,sn);
   $filter=(samaccountname=$USERNAME);
   $sr=ldap_search($ds,dc=radford,dc=edu,$filter,$justthese);
   $info=ldap_get_entries($ds,$sr);
   if ($info==FALSE) {
  DisplayError(unable to find user in the directory.);
  exit;
   }
   if ($info[count]  1) {
  DisplayError(No user account found for $USERNAME);
  exit;
   } else {
  $USER_DN=$info[0][dn];
  // At this point I have the DN for the user I need to
  // bind as this user to see if they entered the correct
  // password.

  // NOTE: This is where my next ldap call will occasionally
  //   (about 5% of the time) creates the seg fault.  
  //   I have tried taking out the ldap_close and 
  //   ldap_connect becuase I should be able to 
  //   just bind again, but I get the same
  //   result either way.
  ldap_close($ds);
  $ds=ldap_connect($ADServer);
  if (!$ds) {
 DisplayError(Unable to bind to ldap server on second
bind);
 exit;
  }
  if (!(ldap_bind($ds,$USER_DN,$PASSWORD))) {
 DisplayError(Invald Password);
 ldap_unbind($ds);
 exit;
  }

Ed OakesPhone: (540) 831-6233
Radford University  Fax:   (540) 831-
Academic Computing  Email: [EMAIL PROTECTED]

http://www.radford.edu/~acadcomp 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] LDAP problems

2001-01-18 Thread Bill . Hoffman

Here is my environment again:

   System Linux [EMAIL PROTECTED] 2.2.5-15 #1 Mon Apr 19 22:21:09 EDT 1999
 i586 unknown
 Build Date Sep 7 2000
 Configure Command './configure' '--with-apxs=/usr/local/apache/bin/apxs'
'
 --with-config-file-path=/usr/local/apache/conf' '--enable-versioning' '
 --with-mysql' '--enable-ftp' '--with-gd=/usr/local/gd' '
 --enable-bcmath=yes' '--disable-debug' '--enable-memory-limit=yes' '
 --enable-track-vars' '
 --with-openlink=/usr/local/odbc' '
 --with-ldap=/usr/local/openldap'
 Server API Apache
 Virtual Directory Support disabled
 Configuration File (php.ini) Path /usr/local/apache/conf
 ZEND_DEBUG disabled
 Thread Safety disabled

Here is my new problem:

  I tried a the new version of PHP  (4.0.4pl1) and openldap (2.0.7) now.
PHP configures fine and compiles fine.  When I go to restart apache it
gives me the following error:

Syntax error on line 237 of /usr/local/apache/conf/httpd.conf:
Cannot load /usr/local/apache/libexec/libphp4.so into server: 
/usr/local/apache/libexec/libphp4.so: undefined symbol: ldap_value_free

Does anyone know what this means or how to make it go away?

The problem with having to compile everything in is now apache and php are down 
because of my ldap problem.  It would be nice if it would start apache
 and php
and give me a message that ldap is not installed.  One bad apple/module should not 
spoil the whole bunch.

Thanx in advance for any help,

BEH


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]