Re: Authenticating through a php script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeremy,

LDAP authentication happens in two stages: connect and bind. The connect
stage is just establishing a connection with the LDAP server
(ldap_connect()). No username or password is necesary in this stage.
Once your connection is established, you attempt a bind (ldap_bind())to
verify a username/password on the LDAP server. Here's some PHP code that
will do it or you:

<?php

$ldap_server = "example.com"; // change to your LDAP server host name
$ldap_port = 389; // might be different for your server
$pw = "yourpassword"; // change to your password
$dn = "cn=dave,ou=people,dc=example,dc=com"; // change to the dn you want to authenticate

$connect_result = ldap_connect( $ldap_server, $ldap_port );

// Did we connect?
if( ! $connect_result )
{
	echo "Could not connect to '$server_name' on port '$server_port'";
}

$bind_result = ldap_bind( $connect_result, $admin_dn, $admin_pw );

// Did we bind?
if( ! $bind_result )
{
	echo "Bad username/password";
}
else
{
	echo "Correct username/password!";
}
	
?>

Here's some good documentation on the topic:
http://www.php.net/manual/en/ref.ldap.php

Let us know how it goes.

--Dave



On Thu, 2003-01-09 at 10:01, Jeremy Peterson wrote:
> I am working on a script that will authenticate on a central system my
> company has devised for us to use (LDAP) and then authenticate them to
> other sites that I want them to access (Online Databases and other
> electronic resources I do not control but pay lots of money for all
> students to access).
> 
> I have seen this done on a product produced by Epixtech called RPA
> (Remote Patron Authentication).  This is an authentication system that
> avoids using a proxy server. It basically handles the authentication
> (LDAP) and sends the appropriate information to the other secure
> source (Online Database, Electronic Resources, or my online catalog's
> patron information.)  Typically there are multiple ways it will
> authenticate for the user to other resources.  URL referer, ip
> authentication, fill in an user/password form for the user.  I just
> can't get the user/password portion to work on a protected site.  My tests 
> of sending post information to another one of my scripts works fine.  But 
> it doesn't work as of yet.
> 
> I have worked a bit with scripts that send post information through
> sendToHost function (fsockopen and fputs).  But nothing is really
> working here.  Does anyone know how I should go about this?  All
> suggestions will be great!
> 
> 
> Thanks a bunch,
> 
> Jeremy



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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux