all groups > dotnet security > may 2007 >
You're in the

dotnet security

group:

Authenticating NT Credentials in C#



Authenticating NT Credentials in C# Matthew Wieder
5/29/2007 8:13:02 AM
dotnet security: I must be missing something since this seems like a common task, but I can't
find any .NET samples of, if given an NT domain/username and password, to
validate that the username and password are correct. LogonUser won't work
since the code needs to run on Windows 2000 without admin priviledges. I
would think there to be a .NET class for this purpose, but the only thing
I've found is the SSPI example here http://support.microsoft.com/?id=180548
Re: Authenticating NT Credentials in C# Matthew Wieder
5/29/2007 10:33:02 AM
The only examples I am able to see that use that class involve writing a
server as well and validating the client against that server. I'm interested
in validating against the NT domain - not my own server.

[quoted text, click to view]
Re: Authenticating NT Credentials in C# Joe Kaplan
5/29/2007 11:11:24 AM
There is a wrapper in .NET 2.0 for SSPI-authenticated streams called
NegotiateStream. You might want to look around for some implementations
that demonstrate how to use it for that purpose.

Joe K.

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
[quoted text, click to view]

Re: Authenticating NT Credentials in C# Joe Kaplan
5/29/2007 3:42:16 PM
I'm not sure how you are supposed to deal with that. If you could connect
to an existing RPC server endpoint that supports SSPI auth (most of them in
Windows), then you could probably get by with just the client. However, I'm
not sure what you are supposed to do there to be honest. Perhaps looking at
one of the C++ samples might give you a clue as to how to go about doing
that.

Another option would be to use LDAP to do the authentication and use the
ability of MS LDAP to do SSPI for authentication. You would need to be able
to find an LDAP server to connect to, but that can usually be located via
DNS/DC locator service if you have the domain name to use.

Joe K.

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
[quoted text, click to view]

Re: Authenticating NT Credentials in C# William Stacey [C# MVP]
5/29/2007 5:37:50 PM
Maybe your doing something different, but the user is already logged on -
corrent? If so, just check the .IsAuthenticated is true on the
WindowsIdentity object for the current session. That way you don't have to
get in the biz of passwords, etc.

--
William Stacey [C# MVP]
Crypt your script
www.powerlocker.com


[quoted text, click to view]
|I must be missing something since this seems like a common task, but I
can't
| find any .NET samples of, if given an NT domain/username and password, to
| validate that the username and password are correct. LogonUser won't work
| since the code needs to run on Windows 2000 without admin priviledges. I
| would think there to be a .NET class for this purpose, but the only thing
| I've found is the SSPI example here
http://support.microsoft.com/?id=180548
| using C++.

Re: Authenticating NT Credentials in C# Dominick Baier
5/31/2007 3:02:06 PM
try this

http://pluralsight.com/wiki/default.aspx/Keith.GuideBook/HowToGetATokenForAUser.html

-----
Dominick Baier (http://www.leastprivilege.com)

Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)

[quoted text, click to view]

Re: Authenticating NT Credentials in C# Grant_S
6/1/2007 6:35:00 AM
Just stumbled across the link (as per prev post) having read this thread
earlier today:
http://www.pluralsight.com/samplecontent/sspi_auth.cpp

[quoted text, click to view]
AddThis Social Bookmark Button