Ok, I'm using the Linq-to AD and I'm having a problem implementing a lambda expression for the where clause in the linq expression.

Basically, I'm getting a MethodCallExpression object of method type Func<User,bool> (user is the object that has all the Active Directory information) and the lambda expression that I put in is

ad.GetUser(x => x.AccountName == "first.last");
.
.
.
GetUser(Func<User,bool> user)
{
.
.
.
var src = from usr in users
                      where user.Invoke(usr)
                      select usr;

foreach (User u in src)
                return u;

I know that the x is of type User, and i can get that, but what I need to be able to do is pull the x.AccountName and the "first.last" from the lambda expression. Anyone have any idea how to do this?

Thanks

I know that the x is of type User, and i can get that, but what I need to be able to do is pull the x.AccountName and the "first.last" from the lambda expression. Anyone have any idea how to do this?

What do you mean by "pull"? You want to inspect the implementation of a Func<>? Why? You are wanting something impossible; the real problem here is that you are wanting it.

The reason that I want it is because the way that the Linq to AD works (atlease for the time being) is by taking the where expression passed into the search, and converting it to an AD search string (e.g. (&(CN='foo')(sAMAccountName='bar')))

but if it's impossible, then I'll find another solution

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.