开发者

How to authenticate LDAP account?

Couple of the Perl applications开发者_如何学C at my workplace require LDAP authentication. When those applications required the user to login, the application would anonymously connect to the LDAP server then searched for the user in the LDAP database. But now, we are no longer allowed to connect to the LDAP server anonymously, we are given a username and password to connect to it.


Some code would be helpful, but, basically, if you have a username and password, you just need to bind to the LDAP directory.

The Net::LDAP documentation has the following example:

$ldap = Net::LDAP->new( 'ldap.umich.edu' );
$mesg = $ldap->bind( 'cn=root,o=University of Michigan,c=us', password => 'secret' );
# your normal code goes here

Alternatively, of course, you could by-pass the username and password you were provided with and simply bind to the directory using the username and password supplied by the user.

Note that if you're binding against Active Directory, it's possible to bind using either 1) the user principal name of the account (e.g., user@umich.edu) or 2) the Kerberos ID (something like UMICH\user) in addition to using the DN of the provided user.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜