.Net C#域账号登陆验证
//获取登陆页输入的域账号、密码
string domainIP = ""; //域IP
string userAccount = ""; //域账号
string Password = ""; //域账号密码
using (DirectoryEntry deUser = new DirectoryEntry(@"LDAP://" + domainIP, userAccount, Password))
{
DirectorySearcher src = new DirectorySearcher(deUser);
src.Filter = "(&(&(objectCategory=person)(objectClass=user))(sAMAccountName=" + userAccount + "))";
src.PropertiesToLoad.Add("cn");
src.SearchRoot = deUser;
src.SearchScope = SearchScope.Subtree; SearchResult result = src.FindOne();
if (result != null)//验证成功
{
DirectoryEntry de = result.GetDirectoryEntry();
string userID = de.Username;
#region 域账号验证通过后判断是否用户在本系统中
var existUser = new DAL.Maintain.UserOP().GetData(userID);
if (existUser == null)
{
ViewBag.ErrorInfo = "提示:您未开通系统的权限,请联系管理员。<br/>You have no access to the system, please contact the administrator!";
return View();
}
#endregion FormsAuthentication.SetAuthCookie(userID, false);
Session.Add("UserID", userID);
Logger.DefaultLog.Info("登陆sessionUserID:" + Session["UserID"].ToString()); if (string.IsNullOrEmpty(ReturnUrl))
{
return Redirect(Url.Action("Index", "Home"));
}
else
{
//...
}
}
else
{
ViewBag.ErrorInfo = "提示:登录失败: 未知的用户名或错误密码。<br/>Account or Password is incorrect!";
return View();
} }
.Net C#域账号登陆验证的更多相关文章
- php接入域账号登陆代码
php接入域账号登陆代码 //替换本地登录为AD域用户认证//edit by ZhangJin on 2015-05-23 -START-$dn = $user_account.'@fun ...
- 如何将VCSA添加到微软域控环境,并且实现微软域账号登陆vCenter
v:* { } o:* { } w:* { } .shape { } p.msonormal,li.msonormal,div.msonormal { margin: 0cm; margin-bott ...
- python实现域账号登陆
需求:公司的网路比较变态,每天到了24点自动断开,为了避免一台测试机断网,用python做了一个自动登录 原理:时间到了24点的时候,每隔10秒检测是否可以ping通www.baidu.com,如果p ...
- 使用Novell.Directory.Ldap.NETStandard在.NET Core中验证AD域账号
Novell.Directory.Ldap.NETStandard是一个在.NET Core中,既支持Windows平台,又支持Linux平台,进行Windows AD域操作的Nuget包. 首先我们 ...
- SharePoint基于windows验证的如何通过组策略实现IE自动以当前域账号登录SP站点
通过组策略实现IE自动以当前域账号登录SP站点 1. 在运行中运行MMC,启动"组策略对象编辑器". 如下图: 找到组策略如下图: 找到域 点右键编辑 找到如下图: 找到[计算机配 ...
- AD域账号验证
public partial class _Default : Page { [DllImport("advapi32.dll")] private static extern b ...
- 通过组策略实现IE自动以当前域账号登录某站点
SharePoint基于windows验证的如何通过组策略实现IE自动以当前域账号登录某站点 1. 在运行中运行MMC,启动“组策略对象编辑器”. 如下图: 2.找到组策略,如下图: 3.找到对应的域 ...
- 通过组策略实现Firefox自动以当前域账号登录MOSS站点---(原创)
忘忧草原创,转发请保留本人的大名,谢谢,如果需要文档的请找我索取 前言 通过组策略实现基于AD的windows验证的sharepoint站点在火狐下自动以当前域账号登录. 操作步骤-在服务器添加策略工 ...
- python学习 登陆验证
#!/usr/bin/env python #-*- coding=utf-8 -*- #----------------导入模块------------------------------ impo ...
随机推荐
- 【HDU1000】A+B Problem
题目来源:www.acm.hdu.edu.cn 题目编号:1000 A+B Problem /*----------------------------------------原题目-------- ...
- [转]Comparing sFlow and NetFlow in a vSwitch
As virtualization shifts the network edge from top of rack switches to software virtual switches run ...
- Spring5中的DispatcherServlet初始化
Spring MVC像许多其它Web框架,被设计围绕前端控制器(DispatcherServlet)实际的工作是由可配置的,委托组件执行提供了一种用于请求处理的共享算法.这个模型是灵活的,支持不同的工 ...
- MySQL索引优化看这篇文章就够了!
阅读本文大概需要 5 分钟. 来源:cnblogs.com/songwenjie/p/9410009.html 本文主要讨论MySQL索引的部分知识.将会从MySQL索引基础.索引优化实战和数据库索引 ...
- 吴恩达机器学习笔记1-单变量线性回归(Linear Regression with One Variable)
在监督学习中我们有一个数据集,这个数据集被称训练集.
- java实操之使用jcraft进行sftp上传下载文件
sftp作为临时的文件存储位置,在某些场合还是有其应景的,比如对账文件存放.需要提供一个上传的工具类.实现方法参考下: pom.xml中引入类库: <dependency> <gro ...
- rabbitmq系统学习(二)
Rabbitmq高级整合应用 RabbitMq整合Spring AMQP实战 RabbitAdmin 使用RabbitTemplate的execute方法执行对应操作 rabbitAdmin.decl ...
- Git:fatal: Authentication failed
1.删除保存的用户名和密码 执行 下面的命令,删除保存的用户名和密码 git config --system --unset credential.helper 重新操作,提示输入用户名和密码,操作成 ...
- LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Sun Jan 13 17:59:19 CST 2019]; root of context hierarch
在运行项目时出现了:LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via ...
- python之获取当前操作系统(平台)
Python在不同环境平台使用时,需要判断当前是什么系统,比如常用的windows,linux等 下面介绍一些能够获取当前系统的命令 1.使用sys.platform获取 #!/usr/bin/env ...