Laravel版本:5.8 Adldap2-Laravel版本:6.0 PHP版本:7.1.3 LDAP类型:ActiveDirectory
您好,凭据是正确的,但我无法通过其登录。 Adlap :: auth()-> attempt()始终返回false。
$user_format = env('LDAP_USER_FORMAT', 'cn=%s,dc=corp,dc=org');
$userdn = sprintf($user_format, $username);
if(Adldap::auth()->attempt($userdn, $request->password , true)) {
return redirect('/home');
} else {
dd($userdn);
}
config / ldap_auth.php
'connection' => env('LDAP_CONNECTION', 'default'),
'provider' => Adldap\Laravel\Auth\DatabaseUserProvider::class,
'model' => App\User::class,
'rules' => [
Adldap\Laravel\Validation\Rules\DenyTrashed::class,
],
'identifiers' => [
'ldap' => [
'locate_users_by' => 'userprincipalname',
'bind_users_by' => 'distinguishedname',
],
'database' => [
'username_column' => 'username',
],
'windows' => [
'locate_users_by' => 'samaccountname'
],
],
'login_fallback' => env('LDAP_LOGIN_FALLBACK', false),
'usernames' => [
'ldap' => 'userprincipalname', // was just 'userprincipalname'
'eloquent' => 'username', // was 'email'
],
'sync_attributes' => [
'username' => 'userprincipalname',
'name' => 'cn',
],
'logging' => [
'enabled' => env('LDAP_LOGGING', true),
答案 0 :(得分:-1)
我解决了。
用户名格式错误。我不需要这些信息。
$user_format = env('LDAP_USER_FORMAT', 'cn=%s,dc=corp,dc=org');
$userdn = sprintf($user_format, $username);
if(Adldap::auth()->attempt($userdn, $request->password , true)) {
现在,我以表格形式输入值。就我而言,name.surname
if(Adldap::auth()->attempt($request->username, $request->password , true)) {