Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My application is created using ASP.net and the authentication is using Windows authentication.Its confusing me,
here they have used WCF for checking user name.Am very new to this WCF.
So i just want to know how they are checking the user name and password from WCF application via windows authentication?
Which one is usual method??
I want to analyze the code and make the report so please help me.
Posted
Updated 4-Dec-12 3:54am
v2

I know 2 ways a web application can do Windows Authentication :

First one : with IIS, if the page is stored in a directory with restricted access (using NTFS access rights for example), the client will be prompted to enter login and password.
The server will receive those (encrypted or not, depending of the IIS configuration) and the ASP.NET object will be called using those credentials (if access granted).

Second one : no server right management, every thing done in the application. In this case, the application may call the Windows function to login to an other account (like in impersonation)
C#
[DllImport("AdvApi32.dll")]
extern static bool LogonUser(string username, string password, string domain, UInt32 LogonType, UInt32 LogonProvider, ref IntPtr hToken); 

Then you can use the System.Security.Principal.WindowsIdentity to manage the account in C# and do the impersonate if necessary.
 
Share this answer
 
Comments
Am Gayathri 5-Dec-12 2:03am    
Here they have used WCF.Do you have any idea about how they are checking username and password in wcf?
Pascal-78 5-Dec-12 3:27am    
WCF is only a set of API in the .NET Framework. It will internally use those kinds of functions.
You can also read this article from Microsoft : http://msdn.microsoft.com/en-us/library/ff647503.aspx (Chapter 5: Authentication, Authorization, and Identities in WCF)
You can use PrincipalContext class to validate user credentials. Get domain, userid and password using a login window and validate as follows.

//Add this reference
using System.DirectoryServices.AccountManagement;

//Use this code for authentication
PrincipalContext pc = new PrincipalContext(ContextType.Domain, txtDomain.Text);
bool bResult = pc.ValidateCredentials(txtUserId.Text, txtPassword.Text);
 
Share this answer
 
Comments
Am Gayathri 5-Dec-12 2:03am    
Here they have used WCF.Do you have any idea about how they are checking username and password in wcf?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900