简体   繁体   English

使用LDAP进行身份验证

[英]Authenticate using LDAP

I have an ssh access to a LDAP server. 我可以通过ssh访问LDAP服务器。

After accessing through ssh I can access to phpldapadmin. 通过ssh访问后,我可以访问phpldapadmin。 I have an admin DN and a password. 我有一个管理员DN和一个密码。

What needs to be done is I have to authenticate users using ldap whenever they try to login to a website. 需要做的是,无论何时尝试登录网站,我都必须使用ldap对用户进行身份验证。

Website is using jaggery for the server side code. 网站正在使用Jaggery作为服务器端代码。 But php is okay too. 但是php也可以。

I haven't worked with ldap and ssh. 我没有使用ldap和ssh。 So if somebody can help on this I'll really appreciate it. 因此,如果有人可以提供帮助,我将非常感激。

You have to download the adLDAP.php here: http://adldap.sourceforge.net/download.php 您必须在此处下载adLDAP.php: http ://adldap.sourceforge.net/download.php

Then the autentication is quiet simple: 然后,增强就很简单了:

$adldap = new adLDAP(array('base_dn'=>'DC=domainexample,DC=suffixexample', 'account_suffix'=>'@domainexample.suffix'));
$authUser = $adldap->authenticate('user', 'password');
if ($authUser == true) {
  echo "User authenticated successfully<br>";
}
else {
  echo "User authentication unsuccessful<br>";
}

You have only to be careful with the DC attribution: it depends on the LDAP network. 您只需要注意DC属性:它取决于LDAP网络。

PHP has an extension to work with LDAP. PHP具有与LDAP一起使用的扩展。 You don't need to install third-party libraries. 您不需要安装第三方库。

Work with ldap and session is what you need. 使用ldap和session是您所需要的。

http://us2.php.net/manual/pt_BR/book.ldap.php http://us2.php.net/manual/pt_BR/book.ldap.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM