私はVB.netに非常に慣れていません。以下のように、ディレクトリ エントリとサーチャーを呼び出すために USING ステートメントを使用できますか。
Using entry As DirectoryEntry = New DirectoryEntry(String.Format("LDAP://xxx.com.my"))
entry.AuthenticationType = AuthenticationTypes.Delegation
entry.Username = username
entry.Password = password
Using searcher As New DirectorySearcher(entry)
searcher.SearchScope = SearchScope.OneLevel
Try
Dim results As SearchResult = searcher.FindOne
success = Not (results Is Nothing)
Catch ex As Exception
success = False
WriteToFile("ValidateADLogin error : " & ex.Message)
End Try
End Using
End Using