Window's Username and Domain helpers.





7
Three little functions to return the Windows Identity, The Envoronment Identoty and the Environment Domain.

        Public Shared Function GetCurrentWindowsIdentity() As String
            Try
                Return System.Security.Principal.WindowsIdentity.GetCurrent.Name
            Catch ex As Exception
                Return String.Empty
            End Try
        End Function

        Public Shared Function GetCurrentEnvironmentIdentity() As String
            Try
                Return System.Environment.UserDomainName + "\" + System.Environment.UserName
            Catch ex As Exception
                Return String.Empty
            End Try
        End Function

        Public Shared Function GetCurrentEnvironmentDomain() As String
            Try
                Return System.Environment.UserDomainName
            Catch ex As Exception
                Return String.Empty
            End Try
        End Function
 

Tim Ehrhart

Comments

Comments Why the try catch?
Sun. Nov. 12th, 2006 11:58 PM    Helper jbplou

Voting