Board logo

標題: [轉帖][ASP]ASP.NET結合AD帳號表單認証 [列印本頁]

作者: eightwing     時間: 2008-9-12 04:57 PM    標題: [轉帖][ASP]ASP.NET結合AD帳號表單認証

<%@ Page Language="VB" Debug="true" %>
<%@ Import namespace="System.Data"%>
<%@ Import namespace="System.Data.OleDb"%>
<html>
<head>
<script language="VB" runat="Server">
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim myComputer As Object
        Dim oIIS As Object
        Dim member As Object
        Dim ret As String
        Dim arr(0) As Object
        arr(0) = "user"

        myComputer = GetObject("WinNT:")
        If TextBox1.Text <> "" Then

            On Error Resume Next
            oIIS = myComputer.OpenDSObject("WinNT://AD網域", TextBox1.Text, TextBox2.Text, 0)
            If Err.Number = 0 Then
                Response.Write("歡迎登入" & TextBox1.Text & "<BR>身分驗證通過.")
            Else
                Response.Write("登入錯誤,請重新登入.<BR>")
            End If

        End If
        If TextBox1.Text = "" Then
            Response.Write("帳號欄位不可空白.<BR>")
        End If

    End Sub
</script>
<title>AD帳號認証</title>
</head>
<body>
<h3>請輸入帳號資料</h3>
<form runat="server">
帳號:<asp:TextBox id="TextBox1" Text="yuchean" width="100px" runat="Server" runat="Server"/><br>
密碼:<asp:TextBox id="TextBox2" TextMode="password" Text="kangta72" width="100px" runat="server" runat="Server"/><br>
<asp:Button id="Button1" Text="送出" runat="Server"/><br>
<asp:Label id="msg" width="200px" ForeColor="red" runat="Server"/>
</form>

</body>
</html>

轉自:
[url]http://blog.blueshop.com.tw/yowcheng/archive/2005/10/05/12153.aspx[/url]




歡迎光臨 下班後論壇-不明所以版  華麗登場 (http://www.eightwing.idv.tw/discuz!/) Powered by Discuz! 3.1.2 Plus