runas other user

juggernot

Well-known member
Joined
Sep 28, 2006
Messages
173
Programming Experience
Beginner
I've created an amateur installer for one of my programs, which places my .exe in start-up. This works fine for users that have administrative privliges, but those who don't get an error. I know how to find out the current username, but I can't seem to find out their rights,(limited, administrative, etc). I want the program to check if they have the proper rights, and if they don't I want a form to pop up where they can run the program as another user who has administrative rights. Is there an easy way to do this?
 
Here how to check role:
VB.NET:
Dim wi As Security.Principal.WindowsIdentity
wi = Security.Principal.WindowsIdentity.GetCurrent
Dim wp As New Security.Principal.WindowsPrincipal(wi)
If wp.IsInRole(Security.Principal.WindowsBuiltInRole.Administrator) Then
    MsgBox("you're administrator")
End If
Here is code to impersonate other user: http://www.vbdotnetforums.com/showthread.php?t=17261
 
Vb.net doesn't show me <SecurityPermissionAttribute, I can't find it. Am i missing an imports statement, or is <SecurityPermissionAttribute only for vb.net2005? I'm running 2003.
 
Back
Top