0

A few custom properties have been added to the user object via CA. I would I retrieve these fields programmatically?

Solution:

     UserProfileManager mgr = new UserProfileManager(SpServiceContext.current);
     UserProfile user = mgr.GetUserProfile(bool);
     String str = (string)user["fields"].Value;
2
  • I think you should change the title, because it's not the SPUser class that you were interested in, in the first place.
    – Norbert
    Commented Dec 12, 2012 at 16:26
  • Will do, but it is the information of the spuser I wanter but I believe I still get the values using the userprofile/userprofile manager
    – user13186
    Commented Dec 12, 2012 at 16:43

2 Answers 2

0

I presume your talking about the code below?

SPSite oSiteCollection = SPContext.Current.Site;
using (SPWeb oWebsite = oSiteCollection.AllWebs["Website_Name"])
{
    SPUser oUser = oWebsite.AllUsers["User_Name"];

    string E-mail_Address = oUser.Email;
    string Display_Name = oUser.Name;
    string User_Notes = oUser.Notes;


    string cutomProp = oUser.CustomeMade;

}

did you add to Microsoft.SharePoint.SPUser? if you have, build save the Microsoft.SharePoint.SPUser. In your project add reference to the new dll (navigate to the folder and goto the bin folder with the updates).

You should now see your changes in the project ;)...... that is if it what your looking for ;)

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spuser.aspx

hope it helps :)

0

You retrieve and set the custom properties the same as any other attribute in the profile property bag.

Here is a powershell script written to import CSV into the User Properties, works for standard and custom fields:

http://iedaddy.com/2010/06/sharepoint-2010-updating-user-profile-properties-with-powershell/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.