国产探花免费观看_亚洲丰满少妇自慰呻吟_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);



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 大庆市| 安吉县| 湘西| 金阳县| 和林格尔县| 藁城市| 雅江县| 叙永县| 雷山县| 肥乡县| 阿荣旗| 常州市| 巴楚县| 额敏县| 高密市| 海南省| 湘西| 平利县| 渭源县| 扶绥县| 河池市| 蕲春县| 中超| 南昌县| 九龙县| 读书| 云阳县| 北安市| 阳新县| 革吉县| 密云县| 元阳县| 疏附县| 苍梧县| 安化县| 宁海县| 冕宁县| 黑水县| 福泉市| 卓尼县| 库尔勒市|