Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Scope to get nsaccountlock #933

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Config/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@
// Only allows users with a uid to authenticate.
// Suitable when using OpenLDAP.
// Adldap\Laravel\Scopes\UidScope::class,

// Fetch the userAccountControl attibute
// This is needed on FreeIPA to determine if an user is disabled
// Adldap\Laravel\Scopes\UserAccountControlScope::class,

],

Expand Down
35 changes: 35 additions & 0 deletions src/Scopes/UserAccountControlScope.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Adldap\Laravel\Scopes;

use Adldap\Query\Builder;

class UserAccountControlScope implements ScopeInterface
{
/**
* {@inheritdoc}
*/
public function apply(Builder $builder)
{
$builder->select($this->getSelectedAttributes($builder));
}

/**
* Retrieve the attributes to select for the scope.
*
* This merges the current queries selected attributes so we
* don't overwrite any other scopes selected attributes.
*
* @param Builder $builder
*
* @return array
*/
protected function getSelectedAttributes(Builder $builder)
{
$selected = $builder->getSelects();

return array_merge($selected, [
$builder->getSchema()->userAccountControl(),
]);
}
}