Re: User Account/Password Validation
Doug Wilson <[email protected]> Thu, 23 Apr 2009 11:34:40 -0700
| Newsgroups | gmane.comp.windows.devel.dotnet.advanced |
|---|---|
| Message-ID | <[email protected]> |
Not sure if this is what you're after or not:
public bool AuthenticateUser(String userName, String password)
{
if (String.IsNullOrEmpty(userName))
throw new ArgumentNullException("userName");
try {
using (DirectoryEntry entry = new DirectoryEntry("WinNT://" +
Environment.MachineName, userName, password)) {
Object obj = entry.NativeObject;
return true;
}
}
catch (DirectoryServicesCOMException) {
}
return false;
}
It can be adapted to work against a domain controller as well.
Doug Wilson
On Thu, Apr 23, 2009 at 10:58 AM, Wilson, Phil
<[email protected]> wrote:
> No - it's a situation where the user is entering an account name that will later be used by a number of services for impersonation. At the time when this is entered we'd like to verify that it is valid.
>
> Phil Wilson
>
>
> -----Original Message-----
> From: Discussion of advanced .NET topics. [mailto:[email protected]] On Behalf Of John Warner
> Sent: Thursday, April 23, 2009 10:23 AM
> To: [email protected]
> Subject: Re: [ADVANCED-DOTNET] User Account/Password Validation
>
> I'm not clear here, are you wanting to replace the GINA?
>
> John Warner
>
>
>> -----Original Message-----
>> From: Discussion of advanced .NET topics. [mailto:ADVANCED-
>> [email protected]] On Behalf Of Wilson, Phil
>> Sent: Thursday, April 23, 2009 1:11 PM
>> To: [email protected]
>> Subject: [ADVANCED-DOTNET] User Account/Password Validation
>>
>> I'm looking for a managed code way to validate a user account (possibly
> in a
>> domain) and password, in particular one that uses SSPI. LogonUser isn't
>> reliable because (as the docs say) the calling user sometimes needs the
>> SE_TCB_NAME privilege. There's a link to some C++ SSPI code in the
>> LogonUser docs that I'd rather not use if I can avoid it.
>> http://support.microsoft.com/kb/180548
>>
>> This isn't an ASP.NET environment, just an existing app needing to
> validate
>> credentials typed into a windows form. I keep thinking I'm missing
> something
>> obvious....
>>
>> Thanks
>>
>> Phil Wilson
>>
>> ===================================
>> View archives and manage your subscription(s) at
>> http://peach.ease.lsoft.com/archives
>
> ===================================
> View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives
>
> ===================================
> View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives
>
>
> ---
> Filter service subscribers can train this email as spam or not-spam here: http://my.email-as.net/spamham/cgi-bin/learn.pl?messageid=7B46C560303011DEB7DC586C93ED0201
>
===================================
View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives