我有使用Apache的LDAP身份驗證。現在我需要知道如何獲得用戶使用PHP登錄的內容。它甚至有可能嗎?我必須在PHP中進行身份驗證來存儲用戶名嗎?如何檢索使用Apache的mod_ldap進行身份驗證的用戶的用戶信息?
2
A
回答
7
我不確定它是否與mod_lsap相同,但是當您使用Apache進行身份驗證時,用戶名和密碼存儲在$ _SERVER的超全局變量中。
$_SERVER['PHP_AUTH_USER']
$_SERVER['PHP_AUTH_PW']
8
如果您激活mod_authnz_ldap模塊模塊和配置部分是這樣的:
<Directory /var/www/yoursite/>
AuthName "LDAP Secured"
AuthType Basic
AuthLDAPUrl "ldap://your.ldap.server:389/dc=example,dc=com?sAMAccountName"
AuthLDAPBindDN "[email protected]"
AuthLDAPBindPassword "secret"
AuthBasicProvider ldap
AuthzLDAPAuthoritative off
Require valid-user
</Directory>
然後在你的PHP代碼,你可以獲取用於登錄如用戶ID這:
<?php
$userId = $_SERVER['AUTHENTICATE_SAMACCOUNTNAME'];
echo "User ID: " . $userId;
<?
您在AuthL中指定的任何LDAP屬性DAPUrl指令可以通過這種方式獲得(以AUTHENTICATE_爲前綴,然後以全部大寫形式附加屬性名稱)。您可以通過用逗號分隔它們來添加更多屬性,但只有第一個屬性將用於身份驗證。進一步的細節見http://httpd.apache.org/docs/2.2/mod/mod_authnz_ldap.html#exposed和http://httpd.apache.org/docs/2.2/mod/mod_authnz_ldap.html#authldapurl。
相關問題
- 1. 從Facebook上檢索經過身份驗證的用戶信息
- 2. 如何以Apache/WebDAV身份驗證的用戶進行讀寫?
- 3. LDAP:如何使用連接詳細信息對用戶進行身份驗證
- 4. Apache中的Kerberos用戶身份驗證
- 5. 運行Apache的PHP進程作爲身份驗證的用戶
- 6. 如何使用Facebook身份驗證檢索Firebase用戶「userID」?
- 7. 使用ManifoldCF進行Apache身份驗證
- 8. Django的私人信息用於身份驗證的用戶
- 9. 檢查用戶是否使用Cognito進行了身份驗證
- 10. 用ubuntu用戶進行Apache WebDAV身份驗證?
- 11. 對用戶進行身份驗證
- 12. 用Apache身份驗證的用戶名覆蓋mercurial用戶名
- 13. EJB:如何檢查用戶進行身份驗證
- 14. 如何使用網站API對用戶進行身份驗證?
- 15. 如何使用遠程API對用戶進行身份驗證?
- 16. 如何使用SOAP對用戶進行身份驗證?
- 17. 如何使用Firebase RESTful API對用戶進行身份驗證?
- 18. 如何使用Shiro對用戶進行身份驗證?
- 19. 如何爲用戶檢索現有的身份驗證令牌?
- 20. 獲取用戶的身份而不進行身份驗證
- 21. 如何使用FormsAuthentication檢測經過身份驗證的用戶?
- 22. Android,從蔚藍表中檢索經過身份驗證的用戶信息
- 23. 使用REST的用戶身份驗證
- 24. 如何在用戶使用Google Adwords進行身份驗證時接收用戶信息OAuth
- 25. Tomcat:使用Windows用戶進行身份驗證的設置
- 26. 使用Crossbar/Autobahn進行用戶通知的身份驗證?
- 27. 使用Dart進行用戶身份驗證的教程
- 28. 如何使用Office-js-helper的身份驗證獲取用戶信息?
- 29. 如何檢查用戶是否需要使用Firebase身份驗證重新進行身份驗證
- 30. 檢索身份驗證信息Azure AD
那麼,這也適用於ldap! :) – scottm 2010-02-10 19:12:41