首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Adldap的无效凭据::search()->users()->get();

使用Adldap的无效凭据::search()->users()->get();
EN

Stack Overflow用户
提问于 2017-06-09 08:31:30
回答 1查看 1.1K关注 0票数 1
  • Laravel版本: 5.4
  • Adldap2-Laravel版本:"^3.0",
  • PHP版本: 5.6.30

我设法使连接工作到AD,但我似乎不能使Auth::尝试工作。永远都是假的。有人有主意或者暗示吗?

代码语言:javascript
复制
public function login(Request $request) {

    $search = Adldap::search()->where('samaccountname', '=', 'tba')->get();
    // this is returning the correct user
    dd($search);

    //'username' => 'tba'
    // 'passwrod' => 'is the entered password'
    //this goes into error part
    if (Auth::attempt(request()->only('username', 'password'))) {
        dd('success');
    } else {
        dd('error');
    }

}

‘用户名’=> [

代码语言:javascript
复制
/*
|--------------------------------------------------------------------------
| LDAP
|--------------------------------------------------------------------------
|
| This is the LDAP users attribute that you use to authenticate
| against your LDAP server. This is usually the users
|'sAMAccountName' / 'userprincipalname' attribute.
|
| If you'd like to use their username to login instead, insert `samaccountname`.
|
*/

'ldap' => 'samaccountname',

/*
|--------------------------------------------------------------------------
| Eloquent
|--------------------------------------------------------------------------
|
| This is the attribute that is used for locating
| and storing the LDAP username above.
|
| If you're using a `username` field instead, change this to `username`.
|
| This option is only applicable to the DatabaseUserProvider.
|
*/

'eloquent' => 'username',

啊对,而且

( Adldap::auth()->attempt(request()->only('username',‘密码’)

为Adldap\Auth\卫队::ErrorException()提供一个ErrorException:缺失参数2,在第63行和defined<中调用

更新:

我终于成功了:

代码语言:javascript
复制
if (Adldap::auth()->attempt(request()->get('username'), request()->get('password'))) {
    dd('success');
} else {
    dd('error');
}

我可以获得成功,奇怪的是,我必须使用CN名称作为用户名。如果我使用samaccountname是"tba“,它就不工作了。

更有趣的是,奥斯根本没有工作。返回假

代码语言:javascript
复制
Auth::attempt(request()->only('username', 'password'))

我需要一些帮助/介绍。

EN

回答 1

Stack Overflow用户

发布于 2017-06-09 08:36:15

我觉得这挺直接的。函数需要2个参数,您要传递给它一个参数。快速查看文档显示,第一个参数是用户名,第二个参数是密码。在执行request()->only('args')时,您将得到一个array

相反,做Auth::attempt(request()-get('username'), request()->get('password'))

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44452972

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档