Forcing NT credentials into CredentialsCache

Posted on 2007-07-30
Last Modified: 2013-11-07
I have a VB.NET running under an NT account (or at least, executed by a user who is logged into the network).

I need to pass that user's credentials through to a webService, but all I get from CredentialsCache.DefaultCredentials is a set of blanks.

I can't force the user to log in as the idea is to get the app to run from a scheduled task with the command line and I don't want to store the user info anywhere since the accounts may change.

So, how can I force the app to run with so that the credentials get set in the credentialscache?

Question by:JohnC28
    LVL 5

    Expert Comment

    both the CredentialCache.DefaultCredentials and CredentialCache.DefaultNetworkCredentials return the Windows Authentication information, you shouble be able use the DefaultCredentials with web services with no problem.
    but you can not see or output the credential details, it will appear blank to you.

    Author Comment

    Thanks - think that partially answers my question (at least, that they will appear blank even if there are there, which appears to be what you are saying???)
    LVL 5

    Accepted Solution

    yes, when you put a breakpoint you will see the domain, username, password are blank.

    you might need to check the authentication setting on the server that hosts the web service to make sure Integrated Windows Authentication is enabled. if your VB client/consumer application is running as current user, the user need able to access the server.

    //here is a simple example to use the DefaultCredentials:
    //after you add the web reference and have the proxy class generated
    Service1 s = new Service1();
    s.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
    object o = s.DoSomething();

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now