Get specific attribut of an AD user #481
-
First of all: sorry for asking! The answer must be really easy to find, but I can't! I'm trying to
What works
But what now? There is the getAttribute() method (https://ldaprecord.com/docs/core/v2/model-api/#getattribute), but it doesn't exist on the returned user object but on these "Models" and I don't understand how they work.... Thx! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @klepptor, You appear to be using both raw queries on your connection and models. I'd suggest sticking with models instead of running raw queries. This should work for you: use LdapRecord\Models\ActiveDirectory\User;
use LdapRecord\Models\ActiveDirectory\Group;
$user = User::findByOrFail('userPrincipalName, '[email protected]');
// $user->getDn(); // Get the users DN (if you need it).
$group = Group::findByOrFail('cn', 'Some Group');
if ($user->groups()->exists($group)) {
// The user is a member of the group.
} Here are the docs for user and group management for Active Directory: https://ldaprecord.com/docs/core/v2/active-directory/users |
Beta Was this translation helpful? Give feedback.
-
Wow, so fast and so good! ;) Thank you very much!!! |
Beta Was this translation helpful? Give feedback.
Hi @klepptor,
You appear to be using both raw queries on your connection and models. I'd suggest sticking with models instead of running raw queries.
This should work for you:
Here are the docs for user and group management for Active Directory:
https://ldaprecord.com/docs/core/v2/active-directory/users
https://ldaprecord.com/docs/core/v2/active-di…