Service References Credentials

By Gord at August 27, 2010 17:06
Filed Under: .Net, .Net Framework 4.0, ASP.NET

There isn't a whole lot of information on using Service References over Web References when it comes to passing in username and password credentials. 

 

Normally with a Web Reference you'd do this:

            MyWebRef.MyClient webClient = new MyWebRef.MyClient();
            NetworkCredential credentials = new NetworkCredential("myUser", "myPassword");
            webClient.Credentials = credentials;

 

 

The Alternative code to that:

            MyServiceRef.MyClient client = new MyServiceRef.MyClient();
            client.ClientCredentials.UserName.UserName = "myUser";
            client.ClientCredentials.UserName.Password = "myPassword";

 

While this may not seem much different, it isn't immediately obvious where to look for setting the username and password inside the Service Reference.

 

 

Windows Services, Data, and Non-domain Servers

By Gord at May 30, 2010 19:01
Filed Under: .Net, Windows Services

There may be instances where you need to move data from one server to another using a Windows service.  Typically your reasons for doing so are to keep certain files sychronized from a common source - for instance, a content management system may need to push files up to multiple web servers, or a BI engine may need file drops moved to a staging folder.  Whatever your reason, it isn't difficult to setup if you follow a list of basics that need to be accomplished:

 

1) Create your Windows service that can move files around locally.  If you can do this, then you can move files between servers too.


2) Assuming the above works, then you'll need to setup a common username/password on all servers.  When doing so, make sure the common username has access to all the folders where files are being read and written.


3) Install your service on one of your servers, ensuring that your service is running under common username/password

 

That's it.  Three steps, and you can move files around between non-domain servers. 

About the author

Gord graduated from Carleton University with a bachelors of Computer Science with minors in both Philosophy and Mathematics.  His post graduate career started in 2005 as a Systems Administrator until becoming a .Net Web Developer 2 years later.  Since then, he has moved on to being a more generic Systems Developer, focusing on intersystem communication, design, and architecture.

Page List