Clicky

I'm trying to authenticate a user against cached credentials for when the domain controller isn't available (i.e. not connected to network).

When I do this I get a System.DirectoryServices.AccountManagement.PrincipalServerDownException.

This works perfectly if I am connected to the network and have access to the domain controller.

Is it possible to do this?

Any help will be appreciated.

Thanks.
 using (PrincipalContext pc = new PrincipalContext(ContextType.Domain)) {    //code }                             
1: 2: 3: 4: 

Select allOpen in new window

asked 04/07/2011 01:01

paulmccann's gravatar image

paulmccann ♦♦


5 Answers:
There is a defaultCredentials that you can use within the CredentialCache.  I needed it for when going over a proxy but you can authenticate off of them.

http://www.qa.downappz.com/Programming/Languages/.NET/ASP.NET/Q_26927781.html

CredentialCache.DefaultCredentials

link

answered

ged325's gravatar image

ged325

Hi.

Thanks for your help.

I'm having trouble authenticating against CredentialCache.DefaultCredentials. Excluding the usual methods (ToString(), GetType(), etc.), there is only the GetCredential() method.
Calling this method returns a NetworkCredential object. Although this object contains properties for username and password, they are empty strings (relieved this is the case from a security point of view).
I was hoping for a method like: bool CheckAuthentication(string Username, string Password).

Any ideas?
link

answered 2011-04-07 at 09:09:08

paulmccann's gravatar image

paulmccann


            Dim u As WindowsIdentity = CredentialCache.DefaultCredentials

            If u.IsAuthenticated Then
                    ' Do something
            end if
link

answered 2011-04-08 at 06:16:57

ged325's gravatar image

ged325

Thanks for the prompt reply.
I cannot assign CredentialCache.DefaultCredentials to a WindowsIdentity object.
If I try to, I get this exception:
InvalidCastException
Unable to cast object of type 'System.Net.SystemNetworkCredential' to type 'System.Security.Principal.WindowsIdentity'.

I've tried:
1:
WindowsIdentity user = CredentialCache.DefaultNetworkCredentials
;
1:
WindowsIdentity user = CredentialCache.DefaultNetworkCredentials.GetCredential(new Uri(@"\DOMAINNAME"), "Basic")
;
1:
WindowsIdentity user = CredentialCache.DefaultCredentials.GetCredential(new Uri(@"\DOMAINNAME"), "Basic")
.

Unfortunately, none of these work, even if I implicitly cast to WindowsIdentity.
link

answered 2011-04-08 at 06:37:16

paulmccann's gravatar image

paulmccann

Not network Credentials.

WindowsIdentity user = CredentialCache.DefaultCredentials;
link

answered 2011-04-08 at 07:24:38

ged325's gravatar image

ged325

Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×59
×68
×82

Asked: 04/07/2011 01:01

Seen: 635 times

Last updated: 12/11/2011 07:40