0

当用户通过从txtboxDomain.Text

using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, txtboxDomain.Text))
{
    // validate the credentials
    bool isValid = pc.ValidateCredentials(txtboxUsername.Text, txtboxPassword.Text);
    if (isValid == true)
    {
        lblLogin.Text = "Valid User Name and/or Password";
        Session["Person"] = txtboxUsername.Text;
        Session.Timeout = 1;
        Response.Redirect("default.htm");
    }
    else
    {
        lblLogin.Text = "Invalid User Name and/or Password";
    }
}

那么,如果用户只想使用本地系统帐户,我该如何编码?(假设本地系统名称是WIN2008R2_LOCAL?

我是否将代码编写为using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, "WIN2008R2_LOCAL"))

(我尝试了上面的代码,但它不起作用。所以想知道我应该如何编码。)

4

1 回答 1

0
PrincipalContext pc = new PrincipalContext(ContextType.Machine, null);
于 2013-01-24T04:37:17.130 回答