[.net] Active Directory authentication error- Unknown error (0x80005000)
I am using following code to access active directory in my Windows application.
1 Dim path = "LDAP://10.10.20.69/OU=dev,DC=abcde,DC=com"
2 Dim userName = txtxUser.Text
3 Dim sUserName = path & "\" & userName
4 Dim passWord = txtPWD.Text
5
6 Dim dirEntry As DirectoryEntry = Nothing
7 Dim searchObject As DirectorySearcher = Nothing
8 Try
9
10 dirEntry = New DirectoryEntry(path, sUserName, passWord)
11
12
13 searchObject = New DirectorySearcher()
14
15 searchObject.SearchRoot = dirEntry
16 searchObject.SearchScope = SearchScope.Subtree
17 searchObject.Filter = "(sAMAccountName=" & userName & ")"
18 searchObject.PropertiesToLoad.Add("CN")
19
20 Dim colQueryResults As SearchResult = searchObject.FindOne() 'error throwing in this line
21
22
23 If colQueryResults IsNot Nothing Then
24 MessageBox.Show("Authentication success")
25 Else
26 MessageBox.Show("Authentication failure")
27 End If
28 Catch ex As Exception
29 MessageBox.Show(ex.ToString)
30 Finally
31 dirEntry.Close()
32 searchObject.Dispose()
33 End Try
When I run this code in Windows 2000 it is working fine. But When i try in 2003 machine it is throwing an exception like this :
System.Runtime.InteropServices.COMException (0x80005000): Unknown error (0x80005000)
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_AdsObject()
at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne)
at System.DirectoryServices.DirectorySearcher.FindOne()
at ADErrortester.Form1.Button1_Click(Object sender, EventArgs e)
Anybody can help in this...?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement