S
Sakinah
Hello guys,
I have write code below to get full name from Active Directory (AD) based on
windows user name (strUserID). When I wrote in Windows Form, it return
value. But I need to show in Web Form but display message error . any idea?
Public Function GetUserInfo(ByVal UserID As String)
Dim ADEntry As New DirectoryServices.DirectoryEntry("LDAP://myDomain")
Dim ADSearch As New System.DirectoryServices.DirectorySearcher(ADEntry)
Dim ADSearchResult As System.DirectoryServices.SearchResult
ADSearch.Filter = ("(samAccountName=" & UserID & ")")
ADSearch.SearchScope = SearchScope.Subtree
Dim UserFound As SearchResult = ADSearch.FindOne()
If Not IsNothing(UserFound) Then
MsgBox(UserFound.GetDirectoryEntry().Properties.Item("name").Value)
End If
End Function
An operations error occurred
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: An
operations error occurred
Source Error:
Line 62: Dim UserFound As SearchResult = ADSearch.FindOne()
I have write code below to get full name from Active Directory (AD) based on
windows user name (strUserID). When I wrote in Windows Form, it return
value. But I need to show in Web Form but display message error . any idea?
Public Function GetUserInfo(ByVal UserID As String)
Dim ADEntry As New DirectoryServices.DirectoryEntry("LDAP://myDomain")
Dim ADSearch As New System.DirectoryServices.DirectorySearcher(ADEntry)
Dim ADSearchResult As System.DirectoryServices.SearchResult
ADSearch.Filter = ("(samAccountName=" & UserID & ")")
ADSearch.SearchScope = SearchScope.Subtree
Dim UserFound As SearchResult = ADSearch.FindOne()
If Not IsNothing(UserFound) Then
MsgBox(UserFound.GetDirectoryEntry().Properties.Item("name").Value)
End If
End Function
An operations error occurred
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: An
operations error occurred
Source Error:
Line 62: Dim UserFound As SearchResult = ADSearch.FindOne()