Quick and dirty way to access Shared Resource Provider (Shared Service Provider) properties

by James 5/1/2008 1:17:00 PM

I have came across a very interesting code today when I tried to access the properties of Shared Services (SSPs) on my farm.

//Use reflection to get SharedResourceProviderCollection on farm

ServerContext sc = ServerContext.Default;

object serverFarm = sc.GetType().GetField("m_ServerFarm", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(sc);

object sharedReourceProviders = serverFarm.GetType().GetProperty("SharedResourceProviders").GetValue(serverFarm, null);

//Loop through each SSP on farm and get its name, user name and password (!)

foreach (object sharedResourceProvider in sharedReourceProviders as IEnumerable)

{

    string sspName = sharedResourceProvider.GetType().GetProperty("Name").GetValue(sharedResourceProvider, null).ToString();

    string sspUserName = sharedResourceProvider.GetType().GetProperty("UserName").GetValue(sharedResourceProvider, null).ToString();

    string sspPassword = sharedResourceProvider.GetType().GetProperty("Password").GetValue(sharedResourceProvider, null).ToString();

}

Although this is not a ideal way to code it, but it does allows you to get what you want (or do what you wanted to do) out from Shared Service Provider.

More properties can be found in

sharedResourceProvider.GetType().GetProperties();

I believe it will come handy in future

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Programming | SharePoint

Comments

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen Adopted by James Tsai

About the author

Name of author James Tsai
.NET / SharePoint Consultant
Columbus, OH

E-mail me Send mail

Calendar

<<  March 2010  >>
MoTuWeThFrSaSu
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234
View posts in large calendar

Certifications

MCPD
MCTS

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

Sign in