DirectoryTree / LdapRecord

A fully-featured LDAP framework.
https://ldaprecord.com
MIT License
512 stars 44 forks source link

[Question] Missing isDisabled() function for AD Users #717

Closed opmx closed 5 months ago

opmx commented 5 months ago

Environment:

Describe the bug: Hey, I'm following the guide to see if an AD account is disabled at https://ldaprecord.com/docs/core/v3/active-directory/users/#checking-user-enablement--disablement and calling if ($user->isDisabled()) But get the error:

Fatal error: Uncaught BadMethodCallException: Call to undefined method LdapRecord\Query\Model\Builder::isDisabled()

I've looked at the source and searched for a function called "isDisabled()" and can't see it. It was present in LdapRecord\Models\ActiveDirectory back in version 2.

Am I doing something wrong?

stevebauman commented 5 months ago

Hi @opmx,

Looks like you're calling ->isDisabled() on a query builder, not a model instance.

Make sure you're retrieving users via get() or find() before calling isDisabled:

Single Result:

$user = User::find('...');

$user->isDisabled();

Multiple Results:

$users = User::get();

foreach ($users as $user) {
    $user->isDisabled();
}