Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Function GetUserProperties()
- Dim ADName As String = GetLogonName()
- Dim CurrentPIN As String = Nothing
- Dim bSuccess As Boolean = False
- Dim dirEntry As DirectoryEntry = GetDirectoryEntry()
- Dim dirSearcher As DirectorySearcher = New DirectorySearcher(dirEntry)
- Dim Q1Value As String = Nothing
- dirSearcher.Filter = ("(samAccountName=" & ADName & ")")
- dirSearcher.PropertiesToLoad.Add("extensionAttribute3")
- dirSearcher.PropertiesToLoad.Add("extensionAttribute4")
- dirSearcher.PropertiesToLoad.Add("extensionAttribute5")
- dirSearcher.PropertiesToLoad.Add("extensionAttribute6")
- dirSearcher.PropertiesToLoad.Add("extensionAttribute7")
- dirSearcher.PropertiesToLoad.Add("extensionAttribute8")
- dirSearcher.SearchScope = SearchScope.Subtree
- Try
- Dim dirResult As SearchResult = dirSearcher.FindOne()
- bSuccess = Not (dirResult Is Nothing)
- If dirResult Is Nothing OrElse dirResult.GetDirectoryEntry.Properties("extensionAttribute3").Value Is Nothing Then
- Return "<not set>"
- Else
- Q1Value = dirResult.GetDirectoryEntry.Properties("extensionAttribute3").Value.ToString
- Q1ComboBox.SelectedIndex = Q1Value
- End If
- 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")
- Application.Exit()
- End Try
- Return False
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement