LINQ to Active Directory

I have found an amazing LINQ to AD open source assembly. Makes life for programming AD very easy here is a sample.

// NOTE: Entity type definition "User" omitted in sample - see samples in release.

var users = new DirectorySource<User>(ROOT, SearchScope.Subtree);

users.Log = Console.Out;

var res = from usr in users

where usr.FirstName.StartsWith("B") && usr.Office == "2525"

select new { Name = usr.FirstName + " " + usr.LastName, usr.Office, usr.LogonCount };

foreach (var u in res)
{

Console.WriteLine(u);u.Office = "5252";

u.SetPassword(pwd);

}

users.Update();

        
Look at how simple that is, if anyone is confused the var is an object created by the LINQ class so you just use it as any normal type. The good thing about this class is that changing any kind of property is very easy and straight forward.  Cool

If you don’t understand LINQ very well here is a URL for some help.

http://msdn.microsoft.com/en-us/netframework/aa904594.aspx

 

Download the LINQ to AD source

http://www.codeplex.com/LINQtoAD/Release/ProjectReleases.aspx?ReleaseId=8629

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



 

Dilbert of the day