简体   繁体   English

源自客户端“ onload”的LDAP查询

[英]LDAP Query originating from client-side “onload”

I have asked previous questions but I think I got too far into pre-conceived notions that I ruled out other options. 我已经问过以前的问题,但是我认为我对排除其他选择的先入为主的观念太过分了。 I'm going to start over: 我将重新开始:

I have tools which are developed and maintained in HTML and JavaScript. 我有使用HTML和JavaScript开发和维护的工具。 What I would like to do is automate the collection of user data. 我想做的是自动收集用户数据。 The users are currently filling in their information and we are storing them in cookies for 6 months. 用户当前正在填写他们的信息,我们将它们存储在Cookie中6个月。 However, If I can have them skip the step of manually inputting this information it'll be a small time savings. 但是,如果我可以让他们跳过手动输入此信息的步骤,将节省少量时间。

If I'm going to be using something server-side I'll be using Microsoft Web Server 2012 with IIS 8.5. 如果要在服务器端使用某些东西,则将使用带有IIS 8.5的Microsoft Web Server 2012。

What I would like to know is: What is the best approach in terms of language? 我想知道的是:在语言方面最好的方法是什么?

Is the best approach a client AJAX call to ASP.Net page which writes the user data back into JSON format? 最好的方法是客户端AJAX调用ASP.Net页面,该页面将用户数据写回JSON格式吗? Should I try authenticated queries or non-authenticated queries? 我应该尝试经过身份验证的查询还是未经身份验证的查询? I'm lost. 我迷路了。

I need recommendations and some guidance with where and how to get started/what I need to learn. 我需要有关从何处开始以及如何开始/需要学习什么的建议和指导。

Update: To be clear, I'm looking for a solution that will be external to my existing code. 更新:明确地说,我正在寻找一种解决方案,该解决方案将在现有代码的外部。 Something that I can access externally (eg AJAX comes to mind) and have it spit back (AD data point indicators): givenName, sn, displayName, telephoneNumber, title. 我可以从外部访问的内容(例如想到的AJAX)并回吐(AD数据点指示符):givenName,sn,displayName,telephoneNumber,title。

There are multiple layers to this. 这有多层。 I order to securely pass data between the client and server, you need to use HTTPS. 为了安全地在客户端和服务器之间传递数据,您需要使用HTTPS。 You can buy a certificate from several websites, but for development lets create a self-signed certificate. 您可以从多个网站上购买证书,但是为了进行开发,请创建一个自签名证书。 In IIS, go to server>Server Certificates>Create Self-Signed Certificate..., enter a name and click on OK. 在IIS中,转到服务器>服务器证书>创建自签名证书...,输入名称,然后单击确定。

Now we need to use that certificate. 现在我们需要使用该证书。 Go to Sites>Add Web Site..., give it a site name, a physical path, in the Binding section, set Type to https, and select the certificate we made in SSL Certificates. 转到“站点”>“添加网站...”,在“绑定”部分中为其指定站点名称,物理路径,将“类型”设置为https,然后选择我们在“ SSL证书”中创建的证书。 Click OK. 单击确定。

If you don't have visual studio, get the express version from https://www.visualstudio.com/vs/visual-studio-express/ . 如果您没有Visual Studio,请从https://www.visualstudio.com/vs/visual-studio-express/获取快速版本。 Once installed, open Visual Studio. 安装后,打开Visual Studio。 Go to File>New Website..., choose Visual C#>ASP.NET Web Site, and click OK. 转到“文件”>“新网站...”,选择“ Visual C#”>“ ASP.NET网站”,然后单击“确定”。

In the Solution Explorer, expand Account and double click on Login.aspx. 在解决方案资源管理器中,展开“帐户”,然后双击Login.aspx。 In the main panel, click on Split to get a view of the HTML and what it will render like. 在主面板中,单击“拆分”以获取HTML及其外观的视图。 Click on the Log In button. 单击登录按钮。 In the Properties panel, click on the lightning bolt to get to actions and double click in the Click option. 在“属性”面板中,单击闪电以进行操作,然后双击“单击”选项。

In here, we will use DirectoryServices, which needs to be referenced in your project. 在这里,我们将使用DirectoryServices,您的项目中需要引用该目录服务。 Right click on the project in Solution Explorer, select Add Reference.... In the .NET tab, select System.DirectoryServices and System.DirectoryServices.AccountManagement, and click OK. 右键单击解决方案资源管理器中的项目,选择“添加引用...”。在.NET选项卡中,选择“ System.DirectoryServices”和“ System.DirectoryServices.AccountManagement”,然后单击“确定”。 Now in Account/Login.aspx.cs in LoginButton_Click enter: 现在,在LoginButton_Click中的Account / Login.aspx.cs中,输入:

bool validUser;
    PrincipalContext ctx  = new PrincipalContext(ContextType.Domain);
    validUser = ctx.ValidateCredentials(this.LoginUser.UserName, this.LoginUser.Password);
    if (validUser) {
        // Do you stuff here.
    }

You now have the very basic LDAP enabled website. 您现在拥有了非常基本的启用LDAP的网站。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM