Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. Private Function GetUserProperties()
  2. Dim ADName As String = GetLogonName()
  3. Dim CurrentPIN As String = Nothing
  4. Dim bSuccess As Boolean = False
  5. Dim dirEntry As DirectoryEntry = GetDirectoryEntry()
  6. Dim dirSearcher As DirectorySearcher = New DirectorySearcher(dirEntry)
  7. Dim Q1Value As String = Nothing
  8. dirSearcher.Filter = ("(samAccountName=" & ADName & ")")
  9. dirSearcher.PropertiesToLoad.Add("extensionAttribute3")
  10. dirSearcher.PropertiesToLoad.Add("extensionAttribute4")
  11. dirSearcher.PropertiesToLoad.Add("extensionAttribute5")
  12. dirSearcher.PropertiesToLoad.Add("extensionAttribute6")
  13. dirSearcher.PropertiesToLoad.Add("extensionAttribute7")
  14. dirSearcher.PropertiesToLoad.Add("extensionAttribute8")
  15. dirSearcher.SearchScope = SearchScope.Subtree
  16. Try
  17. Dim dirResult As SearchResult = dirSearcher.FindOne()
  18. bSuccess = Not (dirResult Is Nothing)
  19. If dirResult Is Nothing OrElse dirResult.GetDirectoryEntry.Properties("extensionAttribute3").Value Is Nothing Then
  20. Return "<not set>"
  21. Else
  22. Q1Value = dirResult.GetDirectoryEntry.Properties("extensionAttribute3").Value.ToString
  23. Q1ComboBox.SelectedIndex = Q1Value
  24. End If
  25. Catch ex As Exception
  26. bSuccess = False
  27. MsgBox("No Connection to the domain." & Environment.NewLine & "Please connect to corporate network & try again.", MsgBoxStyle.Critical, "Network Error")
  28. Application.Exit()
  29. End Try
  30. Return False
  31. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement