Click here to Skip to main content
15,884,010 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi
I am working on a Messaging Application built using WPF and WCF-RESTful site. I am don't have much experience in WCF

This application is used inside intranet as well as internet. The application prompts for authentication (custom login screen in the messaging application) when it accessed through internet (outside the domain).

We have written authentication logic in the WCF service like below,

C#
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, domain))
{
    if (!pc.ValidateCredentials(userName, password, ContextOptions.Negotiate))
    {
        return string.Empty;
    }
}


The Website's application pool is set to use NetworkService. The website's authentication is "Anonymous" as the Intranet User's do not require to authenticate.

I do not get any error or exception. Instead, it always returns "false" for any username even though the credential are correct.

Can you please tell me what I am missing here?

Thanks in Advance.
Posted
Updated 17-Jun-13 1:33am
v3
Comments
Pheonyx 17-Jun-13 6:54am    
Are you getting an error? Is something not working?
So far you've explained what you are doing but not what your issue is (at least not that I can see).
Venkatesh Mookkan 17-Jun-13 7:00am    
Its not throwing any error. It always returns false even though the Username/Password is correct.
Richard C Bishop 17-Jun-13 17:03pm    
In your if statement, you are checking if pc.ValideCredentials() is NOT true. So if it is true, you will get false and therefore never get to the code inside.
Venkatesh Mookkan 17-Jun-13 22:09pm    
Hi Richcb,
The Statement is correct. I have copied only on the code snippet which validates the user. If the Validation fails, it would return Empty string else it would process the further steps.
Richard C Bishop 18-Jun-13 10:12am    
Does pc.ValidateCredentials() return a bool?

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