Query for retrieving "not disabled" users in Active Directory #651
-
Hi, I'm struggling in getting only enabled Active Directory users. I'm using an Scope like this.
It returns: LdapRecord\LdapRecordException If I remove '!'. concat everything it's ok, but I need it with !. Using LdapRecord v3. Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @emiliosh, If you'd like to use it, there is already a built-in query builder method to return only enabled users: LdapRecord/src/Query/Model/ActiveDirectoryBuilder.php Lines 37 to 45 in 496fd44 public function apply(Builder $query, Model $model): void
{
$query->whereEnabled();
} However, if you'd like to do this yourself, try: $query->notFilter(
fn ($query) => $query->rawFilter(
(new AccountControl)->setAccountIsDisabled()->filter()
)
); Let me know if this answers your question! 👍 |
Beta Was this translation helpful? Give feedback.
Hi @emiliosh,
If you'd like to use it, there is already a built-in query builder method to return only enabled users:
LdapRecord/src/Query/Model/ActiveDirectoryBuilder.php
Lines 37 to 45 in 496fd44
However, if you'd like to do this yourself, try:
Let me k…