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

Getting the current login name from SharePoint

Hi guys,

Recently I was creating a Web Part and I needed to get hold of the current login name for comparison. It was simple and didn’t require great amounts of code. Thanks you
SharePoint for making life easier.   Laughing 

string userName = SPContext.Current.Web.CurrentUser.LoginName;

Returns
domain\LoginName

Be the first to rate this post

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

Rolling up data inside Sharepoint, using Search

The recent platform update to WSS and MOSS has bought into play Search Server 2008. Whilst very powerful on it's own. it allows us now to provide roll up funcitonality inside WSS or MOSS.

Previously, roll ups were undertaken using Content Query Web Part, Third Party solutions like our friends at Bamboo or other custom components. For those who don't know what we mean by roll up, it is to take a central view on all content of certain type / property, e.g. all announcements from all webs in all site collections. The diagram below summarises...

Now I was going to type a long blog on how we did it using Search, but to save my fingers (or at least for the moment) take a look at DevCow

Of course, the beauty of the latest infrastructure update is that we now can roll up on the WSS platform.

Search is very powerful, not just for user defined results, but also for other tasks like that above. Hopefully, the next blog post will be a single persons profile, or displaying Business Data Catalog info

UPDATE - October

Something I forgot to mention when I posted the article was that using the normal Search Results web parts, there is a limit on how many items you can display at once without pagination

Be the first to rate this post

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

 

Dilbert of the day