Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 在广告中搜索用户而不使用_Asp.net_Vb.net_Visual Studio 2008 - Fatal编程技术网

Asp.net 在广告中搜索用户而不使用

Asp.net 在广告中搜索用户而不使用,asp.net,vb.net,visual-studio-2008,Asp.net,Vb.net,Visual Studio 2008,我正在创建一个web应用程序,用户需要使用其广告凭据登录。在多个页面上,用户可以使用AD进行另一个用户查找。搜索机制如下所示。问题是它需要使用有效的凭据来创建新的目录条目。在开发过程中,我硬编码了我的凭证,认为每个用户都可以通过在会话变量上保留用户ID和密码来使用他们的凭证。然而,我不确定这种方法是否安全 我想的另一种方法是安排一个程序将广告记录导入数据库,但我还没有找到方法。即使我找到了,程序仍然需要使用特定的凭据,不是吗 我需要一些建议。下面是查找函数的脚本。提前谢谢 Dim

我正在创建一个web应用程序,用户需要使用其广告凭据登录。在多个页面上,用户可以使用AD进行另一个用户查找。搜索机制如下所示。问题是它需要使用有效的凭据来创建新的目录条目。在开发过程中,我硬编码了我的凭证,认为每个用户都可以通过在会话变量上保留用户ID和密码来使用他们的凭证。然而,我不确定这种方法是否安全

我想的另一种方法是安排一个程序将广告记录导入数据库,但我还没有找到方法。即使我找到了,程序仍然需要使用特定的凭据,不是吗

我需要一些建议。下面是查找函数的脚本。提前谢谢

        Dim enTry As DirectoryEntry = New DirectoryEntry(strADSvrIP, user_loginID, user_loginpassword)
        Dim mySearcher As DirectorySearcher = New DirectorySearcher(enTry)


        mySearcher.Filter = "(&(objectCategory=person)(objectClass=user)(|(givenname=" & strKeyword & ")(name=" & strKeyword & ")(sn=" & strKeyword & ")(samAccountName=" & strKeyword & ")))"
        Dim resColl As SearchResultCollection
        Dim resEnt As SearchResult
        Dim list As New List(Of String)

        Try
            resColl = mySearcher.FindAll()

            lblResult.Text = ""

            For Each resEnt In resColl
                If Not resEnt.GetDirectoryEntry.Properties("sn").Value Is Nothing Then
                    lblResult.Text = lblResult.Text & resEnt.GetDirectoryEntry.Properties("samAccountName").Value.ToString() & "-"
                    lblResult.Text = lblResult.Text & resEnt.GetDirectoryEntry.Properties("name").Value.ToString() & "<br>"
                End If
            Next

通常,您会将应用程序池配置为在域帐户下运行。该帐户将用于搜索广告,而无需硬编码用户名和密码


或者,要在用户凭据下搜索广告:如果使用Windows身份验证,则可以调用
HttpContext.Request.LogonUserIdentity.Impersonate()
(或将应用程序或特定页面配置为使用自动ASP.NET模拟)。

我使用的是Classic.NET AppPool。您能否分享如何使用应用程序池和模拟连接到广告?抱歉,我是.NET中的新手。如果您使用
DirectorySearcher
而未指定用户名和密码,则您为应用程序池指定的身份将用于连接到AD。我已尝试将站点身份验证更改为Windows身份验证。但是当我从DirectorySearcher中删除用户名和密码时,它没有返回任何内容。我正在使用Classing.NET AppPool,如何设置标识?感谢链接。我已经阅读了这篇文章并检查了应用程序池的高级设置,它已经指向ApplicationPoolIdentity。但是,当我尝试将此用户添加到某个文件夹的ACL时,我无法获得它。此处不清楚。请不要使用ApplicationPoolIdentity,而是使用特定的域帐户。
        Dim enTry As DirectoryEntry = New DirectoryEntry(strADSvrIP, Nothing, Nothing, AuthenticationTypes.None)