Geeks With Blogs

Tim Murphy

Tim is a Solutions Architect for PSC Group, LLC. He has been an IT consultant since 1999 specializing in Microsoft technologies. Along with running the Chicago Information Technology Architects Group and speaking on Microsoft and architecture topics he was also contributing author on "The Definitive Guide to the Microsoft Enterprise Library".

I review for the O'Reilly Blogger Review Program

Technorati Profile

Tim Murphy's .NET Software Architecture Blog Adventures in Architecting and Developing .NET

When you make a service available external to your corporate network sometimes SSL isn’t secure enough.  If you really want to limit the users who can access a service they need to tied to credentials.  One of the most common credentials to tie to is a Windows account.  What if you are the consumer of these services.

When you add a service reference to a Visual Studio 2010 project it does not give you a chance to set credentials.  The following example is how you can apply credentials to a service reference.

ServiceReference1.MyService servicesClient = new ServiceReference1.MyService();
servicesClient.ClientCredentials.Windows.ClientCredential = new NetworkCredential("myUserName", "myPa$$W0rd", "");

While this example has hard coded credentials that is simply for demonstration.  You could easily (and should) replace these parameters with configured values.  As usual we are not talking about rocket science, but hopefully this tidbit will help a few people.

Posted on Friday, October 7, 2011 1:39 AM Development , WCF | Back to top

Comments on this post: Accessing Authenticated WCF Services

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Tim Murphy | Powered by: | Join free