Provision New User Properties in SSP

This is more of a reminder for me to go back to later, but hopefully, it may help someone else out there.

Since I am provisioning this as part of a feature receiver scoped at the web application level, you will see the "myWebApp" provisioned accordingly,

But if you have any SPSite object, you can get the webapplication directly as a property from there.

Essentially, all I want to do is create a new user property, I can access later through the profile store.

SPWebApplication myWebApp = (SPWebApplication)properties.Feature.Parent;

  

//Set up SSP

ServerContext sc = ServerContext.GetContext(myWebApp);

 

//initialize user profile config manager object

UserProfileConfigManager upcm = new UserProfileConfigManager(sc);

 

//sample to create a new section

PropertyCollection pcol = upcm.GetPropertiesWithSection();

Property prop = pcol.Create(false);

prop.Name = "ServerRedirect";

prop.DisplayName = "Server Redirect";

prop.Type = "string";

prop.Length = 255;

prop.IsUserEditable = true;

prop.IsVisibleOnEditor = true;

prop.IsVisibleOnViewer = true;

prop.IsAlias = false;

pcol.Add(prop);

 

One thing a colleague did make sure to remind me of, was MAKE SURE YOU have provisioned your SSP or this obviously will not work!