Retrieving User Name

  • Thread starter Simon Jefferies
  • Start date
S

Simon Jefferies

Hello,

How do I get the user name (information) for the currently logged in user
using VB. NET?

TIA
Simon Jefferies
Tools Programmer
Headfirst Productions
 
K

Ken Tucker [MVP]

Hi,

Trace.WriteLine(Environment.UserName)

Trace.WriteLine(SystemInformation.UserName)



Ken
 
S

Simon Jefferies

Thanks,

Whats the difference between Environment.UserName and
SystemInformation.UserName?

Regards
Simon Jefferies
Tools Programmer
Headfirst Productions
 
R

Richard

Check out the docs for info on Security and specifically Permissions.

Some code could go: (After importing the System.Security.Permissions
namespace)

AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal)

Dim wp as WindowsPricipal
wp = Ctype(Threading.Thread.CurrentPrinciapl, WindowsPrincipal)

Dim id as WindowsIdentity
id = Ctype(wp.Identity, WindowsIdentity)

Debug.Writeline(id.Name)


*And then use the intellisense or the docs to find the info available
about the identity - theres quite a lot of useful info as you would
expect)
If you then need to ensure a user has specific permissions/authority
to perform a function in your app, and those permissions are based on
Windows security, then you should check out securty checks, like
Demand.

Hth
Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top