我在服务器上有一个活动的目录(窗口)..我想将它与我的网页连接..
这是我的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 ' 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
答案 0 :(得分:2)
ASP.NET Membership也支持Active Directory。看看:
http://msdn.microsoft.com/en-us/library/ms998360.aspx
要手动使用Active Directory,您应该先添加System.DirectoryServices.dll
作为参考。