andy wilson
andy wilson

Reputation: 970

Active Directory authenticate against params on get

I am trying to authenticate the users login against Active Directory, but I am not using the popup Active Directory box, all I am doing is passing the data through when I do the get request to the API. How would I authenticate it because all I know how to do with c# is return a string and bool.

Please help me.

Right now I'm just returning true when someone calls the function how would I go about checking the data correctly and returning a bool to match the answer it gets.

public class AuthController : ApiController
{
    // GET api/auth/Uname+Pword
    public bool Get(string Uname, string Pword)
    {
        return true;
    }
}

Upvotes: 1

Views: 61

Answers (1)

Thang Pham
Thang Pham

Reputation: 621

Authenticate using LDAP in C# is keyword for you.

using(var context = new PrincipalContext(ContextType.Domain, "mydomain", "mydomain\serviceAcct", "serviceAcctPass")) {
 //Username and password for authentication.
 return context.ValidateCredentials(username, password); 
}

Upvotes: 2

Related Questions