String Operations

It's often necessary to do fuzzy searching on strings. I support StartsWith, EndsWith, and Contains operations on strings. More complex fuzzy searches can be done by using the Filter class.

Is should note that some LDAP servers have the best performance when doing StartsWith. Contains and EndsWith will often be much slower. If you try to use any of these operations on a distinguished name property, it will not work.

IQueryable<User> users = context.Query<User>()
     .Where(u => u.FirstName.StartsWith("A"));
// (givenname=A*)

IQueryable<User> users = context.Query<User>()
     .Where(u => u.FirstName.EndsWith("A"));
// (givenname=*A)

IQueryable<User> users = context.Query<User>()
     .Where(u => u.FirstName.Contains("A"));
// (givenname=*A*)

IQueryable<User> users = context.Query<User>()
     .Where(u => Filter.Equal(u, u.FirstName, "some*in*"))
// (givenname=some*in*)

//WILL NOT WORK
IQueryable<User> users = context.Query<User>()
     .Where(u => u.DistinguishedName.Contains("A"));

Last edited Jun 11, 2012 at 5:23 AM by MadHatter22, version 5