开发者

how can i use ActiveDirectory

I have an active Directory (window) on the server ..and i want to connect it with my web pages..

this is my vb code:

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 = UserNa开发者_开发百科me
        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


The ASP.NET Membership supports Active Directory as well. Check it out:

http://msdn.microsoft.com/en-us/library/ms998360.aspx

To use Active Directory manually, you should add System.DirectoryServices.dll as a reference before.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜