Hi,
I have pinched some code from here to see if a user exists in AD.
I am new to VB.NET and having some difficulty in working out where ADHelper comes from.
I have an intellisense error stating ADHelper is not declared. I see that but I am not sure where it comes from for me to declare it.
If I remove ADHelper, I get a runtime error on
Stating "The provider does not support searching and cannot search LDAP://RootDSE"
Here is the code:
If anyone can shed some light on my issue I'd be most greatful.
Many thanks
W
I have pinched some code from here to see if a user exists in AD.
I am new to VB.NET and having some difficulty in working out where ADHelper comes from.
I have an intellisense error stating ADHelper is not declared. I see that but I am not sure where it comes from for me to declare it.
If I remove ADHelper, I get a runtime error on
Code:
Dim results As SearchResultCollection = deSearch.FindAll()
Here is the code:
Code:
Public Function UserExists(ByVal sUserName As String) As Boolean
Dim de As DirectoryEntry = GetDirectoryEntry()
Dim deSearch As DirectorySearcher = New DirectorySearcher()
deSearch.SearchRoot = de
deSearch.Filter = "(&(objectClass=user) (cn=" & sUserName & "))"
Dim results As SearchResultCollection = deSearch.FindAll()
If results.Count = 0 Then
Return False
Else
Return True
End If
End Function
If anyone can shed some light on my issue I'd be most greatful.
Many thanks
W