How do you programmatically retrieve the name of a shared services provider that's associated with a specific Sharepoint web application?
I have a custom solution that needs to:
I got points 1, 3, 4 and 5 figured out, but 2 is somewhat troublesome. I want to avoid hardcoding the SSP name anywhere and not require the farm administrator to manually edit a configuration file. All information I need is in the Sharepoint configuration database, I just need to know how to access it through the object model.
Unfortunately there is no supported way I know of that this can be done. The relevant class is SharedResourceProvider in the Microsoft.Office.Server.Administration namespace, in the Microsoft.Office.Server DLL. It's marked internal so pre-reflection:
SharedResourceProvider sharedResourceProvider = ServerContext.GetContext(SPContext.Current.Site).SharedResourceProvider;
string sspName = sharedResourceProvider.Name;
Post-reflection:
ServerContext sc = ServerContext.GetContext(SPContext.Current.Site);
PropertyInfo srpProp = sc.GetType().GetProperty(
"SharedResourceProvider", BindingFlags.NonPublic | BindingFlags.Instance);
object srp = srpProp.GetValue(sc, null);
PropertyInfo srpNameProp = srp.GetType().GetProperty(
"Name", BindingFlags.Public | BindingFlags.Instance);
string sspName = (string)srpNameProp.GetValue(srp, null);
An alternative would be to write a SQL query over the configuration database which isn't recommended.