UserLock是您的Windows 络守门人,它可以轻松实现有效的Windows和Active Directory 络用户访问控制策略,并严格执行。
最新版UserLock免费下载
会话事件(如登录,注销,锁定,解锁,拒绝登录等)作为JSON消息发送到Web应用程序。然后可以根据特定的访问事件构建自定义工作流。结合UserLock API,它还允许为特定用户配置文件动态创建永久或临时限制,以响应特定事件。
先决条件
安装Visual Studio 2017:
-
ASP.NET和Web开发
-
Azure开发

创建UserLockWebHook MVC Web应用程序
-
在Visual Studio中,通过选择File(文件)>New(新建)>Project(项目)来创建一个项目。
-
在New Project(新建项目)对话框中,选择Visual C#>Web>ASP.NET Web应用程序(.NET Framework)。

选择MVC模板
-
选择MVC模板,并确保将身份验证设置为No Authentication(无身份验证)。

更新所有NuGet软件包并安装NewtonSoft.Json软件包
-
打开工具->NuGet数据包管理器->管理该解决方案的NuGet软件包。
-
打开更新标签,选中Select all packages(选择所有软件包)复选框,然后单击更新按钮。
-
打开浏览选项卡,在搜索字段中输入Newtonsoft.Json并安装软件包。该软件包将用于反序列化UserLock发送的通知。
在模型文件夹中创建以下类
这些类还将在反序列化过程中使用。(下载UserLock可尝试操作)
public class UserLockServer{public string Id { get; set; }public string FQDN { get; set; }public string DisplayName { get; set; }}public class UserlockNotification{public UserLockServer Userlock { get; set; }public int EventType { get; set; }public DateTime EventTime { get; set; }public string UserAccount { get; set; }public string UserDomain { get; set; }public string UserFullName { get; set; }public string ComputerName { get; set; }public int ComputerSession { get; set; }public string ClientName { get; set; }public string ClientAddress { get; set; }public string SessionId { get; set; }public int SubSessionId { get; set; }public int LogonInfo { get; set; }public int SessionType { get; set; }public string ServerAddress { get; set; }public int TimeZoneShift { get; set; }public string Param1 { get; set; }public string Param2 { get; set; }public string Param3 { get; set; }public string Param4 { get; set; }public string Param5 { get; set; }public string Param6 { get; set; }}
更新HomeController
用以下内容替换HomeController类:
public class HomeController : Controller{private static List _notifications = new List();private static List _userLockIds = new List();public ActionResult Index(){Response.AddHeader("Refresh", "3");ReadUserlockIds();return View(_notifications);}private void ReadUserlockIds(){string ids = ConfigurationManager.AppSettings["UserlockIds"];_userLockIds = ids.Split(new char[] { ';' }).ToList();}[HttpPost]public ActionResult Notify(){try{string data = GetPostData(Request.InputStream);UserlockNotification ul = JObject.Parse(data).ToObject();// Is the notification sender valid/ Uncomment the following lines to add a security check// between the webhook application and UserLock service// if (!_userLockIds.Contains(ul.Userlock.Id))// return new HttpStatusCodeResult(HttpStatusCode.OK);// Truncate Userlock Id to avoid displaying sensitive informationul.Userlock.Id = ul.Userlock.Id.Substring(1,8);_notifications.Add(ul);}catch (Exception ex){}return new HttpStatusCodeResult(HttpStatusCode.OK);}private static string GetPostData(Stream inputStream){string data = null;StreamReader reader = new StreamReader(inputStream);try{reader.BaseStream.Position = 0;data = reader.ReadToEnd();}finally{reader.BaseStream.Position = 0;}return data;}public ActionResult About(){return View();}public ActionResult Contact(){return View();}public ActionResult GoToWebsite(){return Redirect("https://www.isdecisions.com");}}
要修复丢失的using语句,请右键单击每个错误,然后选择适当的操作。这些可以在快速操作和重构子菜单中找到。
使用Index方法中的Refresh标头可以自动刷新主页,以便按块显示传入的通知。Notify方法将UserLock通知反序列化为UserLockNotification实例。为了方便起见,选择在HomeController中添加Notify方法。您当然可以决定在另一个控制器(mycontroller / mymethod)中创建其他方法。
安全检查
<appSettings><add key="webpages:Version" value="3.0.0.0" /><add key="webpages:Enabled" value="false" /><add key="ClientValidationEnabled" value="true" /><add key="UnobtrusiveJavaScriptEnabled" value="true" /><add key="UserlockIds" value="{your_userlock_guid1};{your_userlock_guid2};" /></appSettings>
注意:如果您已经部署了UserLock备份服务器,请不要忘记将UserLock备份服务器ID添加到此列表中。
然后,您可以在Notify方法中取消注释行。这样,仅处理声明的UserLock服务器发送的通知。
// Is the notification sender valid/ Uncomment the following lines to add a security check// between the webhook application and UserLock serviceif (!_userLockIds.Contains(ul.Userlock.Id))return new HttpStatusCodeResult(HttpStatusCode.OK);
=========================================
想要了解或购买UserLock正版版权,请咨询官方客服

标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!