Archive

Archive for the ‘MOSS’ Category

Custom UserProfile Property Class for SharePoint

June 25th, 2017 Michael Bell 3 comments

I had a recent project where I needed to bind to the properties in the sharepoint userprofile collection. I found the easiest method was to create an object that contains properties that use the PropertyConstant enumerator to return values from the UserProfile object. It may not be the cleanest, but it let me bind a list of these to a grid, which was what I needed to do.

[Serializable]
 public class UserProfilePropertyObject
 {
 private UserProfile _userProfile = null;

 public UserProfilePropertyObject(UserProfile userProfile)
 {
 _userProfile = userProfile;
 }

 public string FullName
 {
 get { return LastName + ", " + FirstName; }
 }
 public string AccountName
 {
 get
 {
 return (_userProfile[PropertyConstants.AccountName].Value ?? "N/A").ToString();
 }
 }
 public string FirstName
 {
 get
 {
 return (_userProfile[PropertyConstants.FirstName].Value ?? "N/A").ToString();
 }
 }
 public string LastName
 {
 get
 {
 return (_userProfile[PropertyConstants.LastName].Value ?? "N/A").ToString();
 }
 }
 public string Username
 {
 get
 {
 return (_userProfile[PropertyConstants.UserName].Value ?? "N/A").ToString();
 }
 }
 public string WorkPhone
 {
 get
 {
 return (_userProfile[PropertyConstants.WorkPhone].Value ?? "N/A").ToString();
 }
 }
 public string Office
 {
 get
 {
 return (_userProfile[PropertyConstants.Office].Value ?? "N/A").ToString();
 }
 }
 public string Department
 {
 get
 {
 return (_userProfile[PropertyConstants.Department].Value ?? "N/A").ToString();
 }
 }
 public string Title
 {
 get
 {
 return (_userProfile[PropertyConstants.Title].Value ?? "N/A").ToString();
 }
 }
 public string Manager
 {
 get
 {
 return (_userProfile[PropertyConstants.Manager].Value ?? "N/A").ToString();
 }
 }
 public string AboutMe
 {
 get
 {
 return (_userProfile[PropertyConstants.AboutMe].Value ?? "N/A").ToString();
 }
 }
 public string PersonalSite
 {
 get
 {
 return (_userProfile[PropertyConstants.PersonalSpace].Value ?? "N/A").ToString();
 }
 }
 public string Picture
 {
 get
 {
 return (_userProfile[PropertyConstants.PictureUrl].Value ?? "N/A").ToString();
 }
 }
 public string Website
 {
 get
 {
 return (_userProfile[PropertyConstants.WebSite].Value ?? "N/A").ToString();
 }
 }
 public string PublicSiteRedirect
 {
 get
 {
 return (_userProfile[PropertyConstants.PublicSiteRedirect].Value ?? "N/A").ToString();
 }
 }
 public string DottedLineManager
 {
 get
 {
 return (_userProfile[PropertyConstants.Dottedline].Value ?? "N/A").ToString();
 }
 }
 public string Responsibilities
 {
 get
 {
 return (_userProfile[PropertyConstants.Responsibility].Value ?? "N/A").ToString();
 }
 }
 public string Skills
 {
 get
 {
 return (_userProfile[PropertyConstants.Skills].Value ?? "N/A").ToString();
 }
 }
 public string PastProjects
 {
 get
 {
 return (_userProfile[PropertyConstants.PastProjects].Value ?? "N/A").ToString();
 }
 }
 public string Interests
 {
 get
 {
 return (_userProfile[PropertyConstants.Interests].Value ?? "N/A").ToString();
 }
 }
 public string Schools
 {
 get
 {
 return (_userProfile[PropertyConstants.School].Value ?? "N/A").ToString();
 }
 }
 public string SIPAddress
 {
 get
 {
 return (_userProfile[PropertyConstants.SipAddress].Value ?? "N/A").ToString();
 }
 }
 public string Birthday
 {
 get
 {
 return (_userProfile[PropertyConstants.Birthday].Value ?? "N/A").ToString();
 }
 }
 public string MySiteUpgrade
 {
 get
 {
 return (_userProfile[PropertyConstants.MySiteUpgrade].Value ?? "N/A").ToString();
 }
 }
 public string DontSuggestList
 {
 get
 {
 return (_userProfile[PropertyConstants.DontSuggestList].Value ?? "N/A").ToString();
 }
 }
 public string HireDate
 {
 get
 {
 return (_userProfile[PropertyConstants.HireDate].Value ?? "N/A").ToString();
 }
 }
 public string LastColleagueAdd
 {
 get
 {
 return (_userProfile[PropertyConstants.LastColleagueAdded].Value ?? "N/A").ToString();
 }
 }
 public string OutlookWebAccessURL
 {
 get
 {
 return (_userProfile[PropertyConstants.OutlookWebAccessUrl].Value ?? "N/A").ToString();
 }
 }
 public string Assistant
 {
 get
 {
 return (_userProfile[PropertyConstants.Assistant].Value ?? "N/A").ToString();
 }
 }
 public string WorkEmail
 {
 get
 {
 return (_userProfile[PropertyConstants.WorkEmail].Value ?? "N/A").ToString();
 }
 }
 public string MobilePhone
 {
 get
 {
 return (_userProfile[PropertyConstants.CellPhone].Value ?? "N/A").ToString();
 }
 }
 public string Fax
 {
 get
 {
 return (_userProfile[PropertyConstants.Fax].Value ?? "N/A").ToString();
 }
 }
 public string HomePhone
 {
 get
 {
 return (_userProfile[PropertyConstants.HomePhone].Value ?? "N/A").ToString();
 }
 }
 public Guid ID
 {
 get
 {
 return _userProfile.ID;
 }
 }

 }
Categories: MOSS, SharePoint 2007, c# Tags: