H
hch_nguyen
I am developing in the .NET Framework using vb.net running under Windows
2000 SP2. I have a snippet of code that runs to determine the name of the
current windows user logged in. The code works fine when I run it logged in
as a local administrator on the local machine, in other words not logged
into any domain on our network. However, when I log in to the domain on the
same machine, also as local administrator as well as domain admin, the
snippet of code is unable to determine the current user. It errors out. It
gives back just a generic identity as opposed to a window's identity. My
code follows below.
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal)
Dim t As Thread = Thread.CurrentThread
Dim p As Principal.WindowsPrincipal = t.CurrentPrincipal
Dim wi As Principal.WindowsIdentity = p.Identity
Dim fullyQUserName As String = wi.Name
Thanks,
Christine
2000 SP2. I have a snippet of code that runs to determine the name of the
current windows user logged in. The code works fine when I run it logged in
as a local administrator on the local machine, in other words not logged
into any domain on our network. However, when I log in to the domain on the
same machine, also as local administrator as well as domain admin, the
snippet of code is unable to determine the current user. It errors out. It
gives back just a generic identity as opposed to a window's identity. My
code follows below.
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal)
Dim t As Thread = Thread.CurrentThread
Dim p As Principal.WindowsPrincipal = t.CurrentPrincipal
Dim wi As Principal.WindowsIdentity = p.Identity
Dim fullyQUserName As String = wi.Name
Thanks,
Christine