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

Add comment


 

  Country flag

biuquote
  • Comment
  • Preview
Loading



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 and SharePoint consultant

E-mail me Send mail

Calendar

<<  November 2008  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567
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 2008

Sign in