分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 前端开发

.Net域账号登陆验证

发布时间:2023-09-06 02:14责任编辑:郭大石关键词:暂无标签
//获取登陆页输入的域账号、密码string domainIP = "";      //域IPstring 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();} #endregionFormsAuthentication.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域账号登陆验证

原文地址:https://www.cnblogs.com/i-mengli/p/9625551.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved