Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

how to authenticate user password
How to authenticate a user in the web page with the active directory using
perl ldap. Basically what I want is to get the password of the user on the
web page (may be encryted or atleast text) and compare that password thru
LDAP. And if the password matches, wants to display some other page. How
to acheive this thru perl LDAP.

-yelekeri


Report this thread to moderator Post Follow-up to this message
Old Post
Yelekeri
05-13-05 09:30 PM


Re: how to authenticate user password
Hi,

On Friday 13 May 2005 18:06, yelekeri wrote:
> How to authenticate a user in the web page with the active directory using
> perl ldap. Basically what I want is to get the password of the user on the
> web page (may be encryted or atleast text) and compare that password thru
> LDAP. And if the password matches, wants to display some other page. How
> to acheive this thru perl LDAP.

This will not work if the password encryption of ADS is worth its money ;-))
)

but you may use the compare() method of Net::LDAP to compare passwords on th
e
server side or alternatively the bind() method to check if the password is
correct.

Net::LDAP::FAQ should give hints.

Hope it helps
Peter

--
Peter Marschall
eMail: peter@adpm.de

Report this thread to moderator Post Follow-up to this message
Old Post
Peter Marschall
05-14-05 09:14 PM


RE: how to authenticate user password
Hi,

On Friday 13 May 2005 18:06, yelekeri wrote:
> How to authenticate a user in the web page with the active directory
> using perl ldap. Basically what I want is to get the password of the
> user on the web page (may be encryted or atleast text) and compare
> that password thru LDAP. And if the password matches, wants to display

> some other page. How to acheive this thru perl LDAP.


I use bind to achieve this. Below is some sample code. Oh, if you want
things to be a tad more secure, you can use LDAP over SSL....that is if
LDAP over SSL is enabled in your AD forest



($domain,$user,$pass, $execnode, $port)=@ARGV;
use Net::LDAP;

#	Build Search filter

$filter="(\& (userPrincipalName=*$domain*)(sAMAccount
Name=$user))";

#	Set Search node if not passed

if (!$execnode){
print "You must specify an AD Global Catalog Server\n";
exit;
}

$port=3268;

print "NODE:$execnode PORT: $port\n";

#	Get the users DN via anonymous bind to Active Directory. This
assumes that you have enabled anonymous access to AD
#	If you have not, you will have to do an authenticated bind.

#	set the DN to null

$dn="";

#	For performance reasons limit the data returned to the
sAMAccountName

@attr=("sAMAccountName");

if ($ldap = new Net::LDAP("$execnode",port => $port,debug => 0,version
=>3)){

if ($result=$ldap->ldapbind()){

$result=$mesg = $ldap->search(filter => $filter,scope =>
"sub",attrs =>[@attr]);


foreach $entry ($mesg->all_entries) {
$dn=$entry->dn;
}
$ldap->unbind;
}
else
{
print "Anonymous Bind Failed to $execnode\n";
}
}
else
{
print "Initial connect to $execnode failed\n";
}

print "DN: $dn\n";


#	Do an authenticated bind to a domain controller if we have a DN.
Use port 3268
#	so that the controller responds as a Global Catalog Server.


if ($dn){
if ($ldap = new Net::LDAP("$execnode",port => $port,debug =>
0,version =>3)){
if ($result=$ldap->ldapbind('dn' => "$dn",'password' =>
"$pass" )){

$err=$result->code;

if ($err){
if ($err==49){
print "Incorrect username and/or
password (49)";
}
else
{
print "ERROR:$err\n";
}
}
else
{
print "Authenticated!";
}
}
else
{
print "Authenticated Bind Failed to
$execnode\n";
}
}
else
{
print "Initial connect to $execnode failed\n";
}
}
else
{

print "No user found that corresponds to $user\n";
}

Report this thread to moderator Post Follow-up to this message
Old Post
Brian K Johnson
05-14-05 09:14 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

LDAP archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 10:16 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.