This project is read-only.

Collection Operations

Checking to see if a user manages another user or if a group contains a specific user is often a requirement when working with a directory. When using mapped collection properties you can use a Contains operation to check if the property contains the distinguished name. The distinguished name must always be used. Here's an example of checking if a user manages another and if a group contains a user:

string userDn = "CN=John Doe,DN=server,DN=com";
bool managesUser = context.Query<User>()
     .Any(u => u.CommonName == "Jane Doe" && u.Employees.Contains(userDn));
// filter: (&(cn=Jane Doe)(employees=CN=John Doe,DN=server,DN=com))

string userDn = "CN=Jane Doe,DN=server,DN=com";
bool isMemeber = context.Query<Group>()
     .Any(u => u.CommonName == "Manager" && u.Members.Contains(userDn));
// filter: (&(cn=Manager)(members=CN=Jane Doe,DN=server,DN=com))

Last edited Jun 11, 2012 at 6:22 AM by MadHatter22, version 4