How do I validate user credentials

  • Thread starter Thread starter Paul Steele
  • Start date Start date
P

Paul Steele

I'm writing a C# program that needs to validate an Active Directory
username/password? The program will be running on a workstation that is not
part of the domain. It doesn't have to do anything else other than determine
if the credentials are valid. Any pointers would be appreciated.
 
¤ I'm writing a C# program that needs to validate an Active Directory
¤ username/password? The program will be running on a workstation that is not
¤ part of the domain. It doesn't have to do anything else other than determine
¤ if the credentials are valid. Any pointers would be appreciated.
¤

I don't see how this is possible unless the workstation can talk to the domain either directly or
indirectly. One indirect method might be to contact a web service or remote object that is in the
domain through which you are attempting to authenticate.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Paul Clement said:
¤ I'm writing a C# program that needs to validate an Active Directory
¤ username/password? The program will be running on a workstation that is not
¤ part of the domain. It doesn't have to do anything else other than determine
¤ if the credentials are valid. Any pointers would be appreciated.
¤

I don't see how this is possible unless the workstation can talk to the domain either directly or
indirectly. One indirect method might be to contact a web service or remote object that is in the
domain through which you are attempting to authenticate.

The workstation does have access to the domain (such as the domain
controller) so that should not be an issue (I hope). I've just haven't
figured out how to do within my C# program. I've found lots of examples that
I thought would work but no luck so far. There's got to be a way to validate
credentials in this sort of situation.
 
I solved my own problem. Here's the sample code:

try
{
IADsOpenDSObject user = (IADsOpenDSObject)Utils.GetObject("WinNT:");
user.OpenDSObject("WinNT://ad.acadiau.ca",username,password1,
(int)ADS_AUTHENTICATION_ENUM.ADS_SECURE_AUTHENTICATION);
return true;
}
catch
{
return false;
}

 
¤ I solved my own problem. Here's the sample code:
¤
¤ try
¤ {
¤ IADsOpenDSObject user = (IADsOpenDSObject)Utils.GetObject("WinNT:");
¤ user.OpenDSObject("WinNT://ad.acadiau.ca",username,password1,
¤ (int)ADS_AUTHENTICATION_ENUM.ADS_SECURE_AUTHENTICATION);
¤ return true;
¤ }
¤ catch
¤ {
¤ return false;
¤ }
¤

Looks like you're using the COM based ADSI implementation. You can also use the .NET
System.DirectoryServices library:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/dotnetadsearch.asp
(Authenticating to Your Directory)


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top