DirectoryTree / LdapRecord

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

[Support] #682

Closed Arkantium closed 7 months ago

Arkantium commented 8 months ago

Hi,

How to make a query to search if an object exists only in a list of OU selection? I have try with Raw filter but no success

Environment:

stevebauman commented 7 months ago

Hi @Arkantium,

I'm not sure what you mean. Can you elaborate and share a code example? Also, please add a title to the issue.

Arkantium commented 7 months ago

Hmm.

I want my user can only see the object in this two OU

OU=0818_CASTELLI,OU=Adherents,OU=Infra_Ceicom,DC=gedimat,DC=fr and OU=0818_CASTELLI,OU=Adherents,DC=gedimat,DC=fr

I try to make an scope for block user in this two OU

stevebauman commented 7 months ago

LDAP searches can only be performed on one OU at a time. For LDAP to perform a search inside of an OU, it needs to be set as the base DN of the query, and an LDAP query can only have one base. This isn't a limitation of LdapRecord, but a limitation of the protocol itself.

To see all users in a particular OU, call the in() method on the query:

use LdapRecord\Models\ActiveDirectory\User;

$users = User::in('OU=0818_CASTELLI,OU=Adherents,DC=gedimat,DC=fr')->get();

$users = $users->merge(
    User::in('OU=0818_CASTELLI,OU=Adherents,OU=Infra_Ceicom,DC=gedimat,DC=fr')->get()
);

Hope this helps!