|
-
Nov 27th, 2003, 07:35 AM
#1
Thread Starter
Fanatic Member
How to get the name of the logged in user
In VB6 we used the GetUserName API call to get the id of the user logged in to the network.
The application lives on a network drive.
When I converted the application in VS.net 2003 and ran it I got a security error. Saying something about security permissions do not allow the action to take place.
When I moved the application to the local C drive the error did not appear.
The equivalent to GetUserName in .net is System.Security.Principal.WindowsIdentity.GetCurrent.Name. When I added this to a project I started getting different errors.
How can I have an application on a network drive and read the user id.
Is this going to be a big issue involving the IT dept.
Any help would be appreciated.
-
Nov 27th, 2003, 08:55 AM
#2
Have you tried
Environment.UserName
?
I don't live here any more.
-
Nov 27th, 2003, 10:49 AM
#3
Addicted Member
I'm not sure, but I think you may have to do one or both of the following:
1) Give your application greater security in the GAC.
2) Give your application greater security using one of the classes (I can't remember which one) in the Security namespace.
-
Nov 27th, 2003, 12:06 PM
#4
Thread Starter
Fanatic Member
wossname: I haven't tried that, I will later.
Sheppe: I don't really know anything of what you said. GAC? Or how to do 2.
I guess theres lots to learn.
-
Nov 27th, 2003, 06:20 PM
#5
PowerPoster
-
Nov 29th, 2003, 01:19 PM
#6
Thread Starter
Fanatic Member
Thanks,
That looks like it will do the trick.
-
Dec 1st, 2003, 10:56 AM
#7
Thread Starter
Fanatic Member
I am not a member of EE so I could not see the solution.
Thanks wossname that worked a treat
-
Dec 1st, 2003, 11:09 AM
#8
yay gay
Originally posted by davidrobin
I am not a member of EE so I could not see the solution.
Thanks wossname that worked a treat
Next time look at all the page as the answer was right bellow
VB Code:
User name
GetUserName = (SystemInformation.UserName.ToString)
Domain/User
Imports System
Imports System.Security
Private Function GetUserName() As String
Return Principal.WindowsIdentity.GetCurrent.Name()
' This will return 'domain\username'
End Function
\m/  \m/
-
Dec 1st, 2003, 11:13 AM
#9
Thread Starter
Fanatic Member
Sorry, my mistake
That is useful to know as well.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|