using Microsoft.Office.Server;
using Microsoft.Office.Server.UserProfiles;
The first step is to get a reference to the UserProfileManager. You’ll need to pass in a reference to the current SSP by using ServerContext.Current.
UserProfileManager userProfileManager = new UserProfileManager(ServerContext.Current);
After that you get the current user’s profile. Passing true, will create the user’s profile if it doesn’t exist.
UserProfile currentUser = userProfileManager.GetUserProfile(true);
The QuickLinkManager class provides what we need to add, remove, or iterate through the links the user currently has.
QuickLinkManager quickLinkManager = currentUser.QuickLinks;
quickLinkManager.Create("My Quick Link", "http://www.dotnetmafia.com", QuickLinkGroupType.General, null, Privacy.Private);
You can also iterate through the user’s QuickLinks pretty easily using the GetItems() method. For example:
foreach (QuickLink quickLink in quickLinkManager.GetItems())
{
Console.WriteLine(quickLink.Url);
}
No comments:
Post a Comment