Support the ongoing development of Laravel.io →
Authentication
Last updated 2 years ago.
0

Have you set the correct 'username_field' on your auth.php ?

On my case:

'username_field' => 'username',
Last updated 2 years ago.
0

I just tried that and it still exhibited the same behavior. Auth::attempt(...) fails, $ad->authenticate(...) works fine.

I hadn't put it in there previously, because the docs said "This will default to username if you don't provide one," which is what I assumed I needed anyway.

Thank you, though.

Last updated 2 years ago.
0

Alright, I think I have this figured out. The issue is that I haven't provided provided admin_username and admin_password in the config (because I didn't have one to use).

If you provide the appropriate admin credentials, it will bind to AD immediately upon connect using those credentials, and Auth::attempt(...) works fine because you're already bound to AD by the time it tries to run retrieveByCredentials(...), so it can run the user query ($this->ad->user()->infoCollection($user, array('*'));) just fine. Without admin credentials, however, you're not bound yet, infoCollection(...) returns false, and you get nothing.

I entered my own (non-admin) user and pass into the appropriate config entries, and sure enough, it worked perfectly, at least when trying to Auth:attempt(...) my own account again. The next thing to try will be to get a real admin account from the network guy and see if it still works.

So the solution is basically that admin_username and admin_password are actually required, despite what the readme says, if you want to be able to use it as a direct replacement for Eloquent's Auth::attempt(...) method.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.