国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

在ASP.Net 中使用實現windows登陸的方法

2024-07-10 13:05:18
字體:
來源:轉載
供稿:網友
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);



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 武陟县| 台山市| 锦屏县| 威远县| 香港| 裕民县| 樟树市| 仙居县| 深泽县| 瓦房店市| 尚志市| 永德县| 云南省| 宁津县| 饶河县| 汤阴县| 元朗区| 英超| 嘉善县| 平顶山市| 神池县| 澎湖县| 政和县| 谢通门县| 北川| 南华县| 上思县| 天等县| 乐平市| 衡阳县| 星座| 喀什市| 鹤壁市| 蛟河市| 贵港市| 金寨县| 自贡市| 白沙| 扎囊县| 永川市| 华安县|