Posts
411
Comments
228
Trackbacks
42
Accessing Authenticated WCF Services

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", "mydomain.com");

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 Print
Comments
No comments posted yet.

Post Comment

Title *
Name *
Email
Comment *  
 

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

www.flickr.com
Tag Cloud