Vb.net 如何使用ActiveDirectory
我在服务器上有一个active Directory(窗口)。我想将它与我的网页连接 这是我的vb代码:Vb.net 如何使用ActiveDirectory,vb.net,Vb.net,我在服务器上有一个active Directory(窗口)。我想将它与我的网页连接 这是我的vb代码: Imports System Imports System.Collections.Generic Imports System.Linq Imports System.Data Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.DirectoryServices
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Data
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.DirectoryServices ' cannot be found '
Imports System.Runtime.InteropServices
Imports System.Configuration
Imports System.Data.SqlClient
Partial Class Default3
Inherits System.Web.UI.Page
Public Function IsADUser(ByVal UserName As [String], ByVal Password As [String]) As [Boolean]
Dim entry As New DirectoryEntry()
entry.Username = UserName
entry.Password = Password
Dim searcher As New DirectorySearcher(entry)
searcher.Filter = "(objectclass=user)"
Dim Authentecated As [Boolean] = False
Try
searcher.FindOne()
Authentecated = True
Catch ex As COMException
Authentecated = False
End Try
Return (Authentecated)
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
End Class
ASP.NET成员资格也支持Active Directory。请查看: 要手动使用Active Directory,您应该在之前添加
System.DirectoryServices.dll
作为参考