Shared Function ExtractUser(ByVal pvbooIncludeServer As Boolean) As String
'******************************************
'* Extract the NT User LOGIN Name *
'******************************************
Dim objMyIdentity As System.Security.Principal.WindowsIdentity
Dim objMyPrincipal As System.Security.Principal.WindowsPrincipal
Dim strUser As String
Dim intLastSlashIndex As Int32
objMyIdentity = System.Security.Principal.WindowsIdentity.GetCurrent()
objMyPrincipal = New System.Security.Principal.WindowsPrincipal(objMyIdentity)
strUser = String.Format("Logon name: {0}", objMyIdentity.Name)
If Not pvbooIncludeServer Then
If strUser <> "" Then
intLastSlashIndex = strUser.LastIndexOf("\")
If intLastSlashIndex <> -1 Then
strUser = strUser.Substring(intLastSlashIndex + 1)
End If
End If
End If
Return strUser
End Function