public bool login(string username, string password, string domain)
{
string text1 = domain.trim();
string text2 = username.trim();
text2 = text2.replace("/", @"/");
int num1 = text2.indexof('//');
if (num1 != -1)
{
text1 = text2.substring(0, num1);
text2 = text2.substring(num1 + 1);
}
else
{
num1 = text2.indexof('@');
if (num1 != -1)
{
text1 = text2.substring(num1 + 1);
text2 = text2.substring(0, num1);
}
}
return this.authenticateuser(text2, password.trim(), text1);
}
private bool authenticateuser(string username, string password, string domain)
{
bool flag1 = false;
try
{
int num1;
intptr ptr1;
if (!windowsauth.logonuser(username, domain, password, 2, 0, out num1))
{
return flag1;
}
ptr1 = new intptr(num1);
windowsidentity identity1 = new windowsidentity(ptr1);
windowsprincipal principal1 = new windowsprincipal(identity1);
httpcontext.current.user = principal1;
formsauthentication.setauthcookie(principal1.identity.name, false);
formsauthentication.redirectfromloginpage(username, false);
flag1 = true;
}
catch (exception)
{
}
return flag1;
}
[dllimport("advapi32.dll")]
public static extern bool logonuser(string lpszusername, string lpszdomain, string lpszpassword, int dwlogontype, int dwlogonprovider, out int phtoken);