Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.
Private Function GetUserProperties() As ADProperties Dim ADName As String = GetLogonName() Dim bSuccess As Boolean = False Dim dirEntry As DirectoryEntry = GetDirectoryEntry() Dim dirSearcher As DirectorySearcher = New DirectorySearcher(dirEntry) Dim waitTime As TimeSpan = New TimeSpan(0, 0, 0, 5, 0) dirSearcher.ClientTimeout = waitTime dirSearcher.Filter = ("(samAccountName=" & ADName & ")") dirSearcher.PropertiesToLoad.Add("manager") dirSearcher.SearchScope = SearchScope.Subtree Try Dim dirResult As SearchResult = dirSearcher.FindOne() bSuccess = Not (dirResult Is Nothing) If dirResult.GetDirectoryEntry.Properties("manager").Value Is Nothing Then GetUserProperties.manager = "<Not Set>" Else GetUserProperties.manager = (dirResult.Properties("manager")(0).ToString()) End If bSuccess = True Catch ex As Exception bSuccess = False MsgBox("No Connection to the domain." & Environment.NewLine & "Please connect to corporate network & try again.", MsgBoxStyle.Critical, "Network Error #1") Application.Exit() End Try End Function
Join the community of 500,000 technology professionals and ask your questions.