ADO DOT NET Posted February 27, 2008 Posted February 27, 2008 Hi, I want to check if my user is admin or not? IF not, give him a nice error and End my application! I only need to run this in Windows XP, Vista and Server 2003 ! I have these 2 codes: CODE 1: If My.User.IsInRole(ApplicationServices.BuiltInRole.Administrator) Then End End If CODE 2: Dim wp As New WindowsPrincipal(WindowsIdentity.GetCurrent()) If wp.IsInRole(WindowsBuiltInRole.Administrator) = False Then End End If I just wanna know which one is correct and better to use for me? What's the different between these two? Thank you. Quote
Administrators PlausiblyDamp Posted February 27, 2008 Administrators Posted February 27, 2008 Looking at the il with ildasm it appears that the My.User.... function ultimately calls the WindowsPrincipal.IsInRole method anyway. Other than that I can't really see any major difference, personally I would tend to avoid the My.... methods simply because I use both vb and c# so I try to use functionality that is present in both (less for me to remember that way) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.