Monday, June 30, 2008

Accessing my site data programmatically.

My site is perfect place to store personalize data.
But accessing my site programmatically is not an easy task.

There is always a big question that “How to access my site personalize data programmatically?”

Here is the solution.

First you have to import

Microsoft.Office.Server.dll

We are not using it normally. (At least not me)

Then you have to set
ServerContext context = = ServerContext.Current;
UserProfileManager profilmanager = new UserProfileManager(context);
UserProfile profile = profilmanager.GetUserProfile(SPContext.Current.Web.CurrentUser.LoginName);


This is the way you can find profile of current user.
After getting profile you can use personalize data.

My links
QuickLinkManager qlmanager = new QuickLinkManager(profile);
QuickLink[] ql = qlmanager.GetItems();
Or
profile.QuickLinks.get ;

My Colleague
ColleagueManager colmanager = new ColleagueManager(profile);
Colleague[] cl = colmanager.GetItems();
Or profile.Colleagues.GetItems();

My Membership
MembershipManager memmanager = new MembershipManager(profile);
Membership[] memship = memmanager.GetItems();
Or
profile.Memberships.GetItems();

It works for me.
Try it out.

3 comments:

Anonymous said...

Hi Parth,
Great work man,it works for me.
-Jayesh

Ali Raza said...

how can i access detail link information like phone number, picture and all other details.


Thanks in advance

Ali Raza said...

can you please help me out, how to get detail information of personal site. like picture, phone number and other details

Thanks in advance




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com