我試圖用Symfony的3.2認證通過LDAP(窗口活動目錄)用戶配置的服務和保障爲每documentsSymfony的3.2 LDAP身份驗證問題
但我得到的錯誤:
php.DEBUG: Warning: ldap_bind(): Unable to bind to server: Invalid credentials {"exception":"[object] (Symfony\Component\Debug\Exception\SilencedErrorContext: {\"severity\":2,\"file\":\"/var/www/html/workflow/vendor/symfony/symfony/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php\",\"line\":54})"} []
嘗試了諸如添加域{username} 或完全從ldap search softerra複製cn字符串等參數的更改。
security.yml
:
security:
providers:
my_ldap:
ldap:
service: ldap
base_dn: dc=example,dc=example
search_dn: "cn=user.name,DC=example,DC=example"
search_password: PassWord
default_roles: ROLE_ADMIN
uid_key: sAMAccountName
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
# an`enter code here`onymous: ~`enter code here`
http_basic_ldap:
service: ldap
dn_string: 'uid={username},dc=example,dc=example'
access_control:
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/, roles: ROLE_ADMIN }
service.yml
:
services:
ldap:
class: Symfony\Component\Ldap\LdapClient
arguments:
- ip # host
- portenter code here # port
- 3 # version
- false # SSL
- false # TLS
native php
:
<?php
$name = '[email protected]';
$pass = 'password';
$adServer = 'ldap://xxx.xxx.xxx.xxx:1234/';
$basedn="OU=Users,OU=Office,OU=xxx,DC=xxx,DC=xxx"
$filter="(&(!(ou=NoSync))(department=*)(sn=*))";
$attributes=array("displayname", "mail", "company", "department", "physicaldeliveryofficename", "memberOf","givenname","sn","manager",
"mobile", "ipphone", "telephoneNumber", "facsimiletelephonenumber", "streetaddress", "l", "st","userprincipalname",
"postalcode", "c", "title", "samaccountname", "useraccountcontrol");
$cnx = ldap_connect($adServer) or die("Could not connect to LDAP server.");
ldap_bind($cnx, $name, $pass);
ldap_set_option($cnx, LDAP_OPT_SIZELIMIT,10000);
ldap_set_option($cnx, LDAP_OPT_PROTOCOL_VERSION, 3) or die ("Could not set ldap protocol");;
ldap_set_option($cnx, LDAP_OPT_REFERRALS, 0) or die ("Could not set option referrals");
ldap_control_paged_result($cnx, 1000) or die ("Could not set option page limit");
$pageSize = 900;
$total='';
$cookie = '';
$arr_rec=[];
$arr_rec_update=[];
do {
$total = $pageSize + $total;
ldap_control_paged_result($cnx, $pageSize, true, $cookie);
$result = ldap_search($cnx,$basedn,$filter,$attributes);
$entries = ldap_get_entries($cnx, $result);
?>
由用戶我試圖他們進行身份驗證的方式如果我使用本地php ldap腳本,則可以成功通過身份驗證。 –
你能告訴我們你正在使用本機php的php腳本嗎?這可能有助於發現配置問題。 – COil
嗨,感謝您提供幫助 –