Met deze functie kunt u de username filteren uit windows voor bijvoorbeeld login systemen of sql logins of andere doeleinde. Code:
Function GetUserName() As String If TypeOf My.User.CurrentPrincipal Is _ Security.Principal.WindowsPrincipal Then ' The application is using Windows authentication. ' The name format is DOMAIN\USERNAME. Dim parts() As String = Split(My.User.Name, "\") Dim username As String = parts(1) Return username Else Return My.User.Name End If End Function
|