由於要寫鼎新自動登入的動作,所以有以下的程式
Imports System.DirectoryServices
Imports System.Environment
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim domainAndUsername As String = UserDomainName & "\" & UserName
Dim entry As DirectoryEntry = New DirectoryEntry("LDAP://your.com.tw", domainAndUsername, "YourADpassword")
Dim obj As Object = entry.NativeObject
Dim search As DirectorySearcher = New DirectorySearcher(entry)
search.Filter = "(SAMAccountName=" & UserName & ")"
search.PropertiesToLoad.Add("cn")
Dim result As SearchResult = search.FindOne()
If (result Is Nothing) Then
MsgBox("You ain't correct user")
End If
End Sub
End Class
沒有留言:
張貼留言