在ASP.Net 中使用实现windows登陆的方法.
来源:互联网 发布:黄金探测器软件下载 编辑:程序博客网 时间:2024/04/28 02:53
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);
- 在ASP.Net 中使用实现windows登陆的方法.
- ASP.Net 中使用实现windows登陆的方法
- 在ASP.Net 中使用实现windows登陆的方法. (轉自tainkai的專欄.http://blog.csdn.net/tainkai)
- 如何在ASP.net中实现限制一个用户名在多个客户端IE登陆的方法
- 如何在ASP.net中实现限制一个用户名在多个客户端IE登陆的方法
- 在 ASP.NET 中实现不同角色的用户使用不同登录界面的方法
- 在 ASP.NET 中实现不同角色的用户使用不同登录界面的方法
- 在 ASP.NET 中实现不同角色的用户使用不同登录界面的方法
- 在 ASP.NET 中实现不同角色的用户使用不同登录界面的方法
- 在 ASP.NET 中实现不同角色的用户使用不同登录界面的方法
- 在 ASP.NET 中实现不同角色的用户使用不同登录界面的方法
- 在ASP.net中使用域账号进行登陆
- 在ASP.NET 2.0中数据绑定的实现方法
- 在asp.net中实现datagrid checkbox 全选的方法
- 在asp.net中fso的使用的方法
- 在Asp.Net中使用SmtpMail发送邮件的方法
- 在Asp.Net中使用SmtpMail发送邮件的方法
- 在ASP.NET中使用AJAX的简单方法
- ASP.NET 入門套件
- XML文章大全
- String.Intern 方法
- 请直接回复留言即可
- YaMei Has Come Back from Abroad
- 在ASP.Net 中使用实现windows登陆的方法.
- 11种流行的木马清除方法
- Visual C++.NET第四章开始
- An introduction to weblog terms for weblog readers
- 炼功常见问题
- 头发长了 想法儿却少了
- Eclipse3.0下配置JBoss3.2.5
- QQ浏览器Session问题
- SSI使用详解1