2 years ago

Login via Active Directory and limited access

Posted 2 years ago by cservices

I am using Adldap2 to connect to our Active Directory. I have never done anything like this before, and still getting used to Laravel.

In a previous app I had created a gate:

Gate::define('superadmin', function ($user) { return $user->superadmin == 1; });

This worked very well for me.

If I am to understand Adldap2 correctly, and having yet to connect to the Active Directory, when an attempt to login is successful, it will write the user to the 'users' table in the app.

But how do I limit the access to only certain users? Especially since I am not allowed to edit or make changes to the Active Directory.

There are hundreds of people in the Active Directory, but only a handful are to have access to the backend of the app. Can the users be assigned to the 'users' table before they try to use the login via the Active Directory? If not, can I have a field in the table (like “superadmin”) that defaults to null, then manually edit the table and change the value to 1 and have a gate similar as above?

Thanks in advance for your help.

Please sign in or create an account to participate in this conversation.