Tutorials
Resources
Forum
Communities
Interview
Jobs
Projects
Offshore Development
Silverlight Tutorials
|
Mentor
|
Code Converter
|
Articles
|
Code Factory
|
Computer Jokes
|
Members
|
Peer Appraisal
|
IT Companies
|
Bookmarks
|
Revenue Sharing
|
Prizes & Awards
My Profile
Sign In
Register
AdSense Revenue
Active Members
Today
divya
(34)
Babu Akkandi
(28)
Abhi
(28)
Last 7 Days
Appukuttan
(620)
Babu Akkandi
(465)
Tejinder Singh ...
(273)
more...
New Feature:
Community Sites
:
Create your own .NET community website and start earning from Google AdSense !
It's Free !
Check if the user is Administrator
Posted Date: 14 May 2008
Resource Type:
Code Snippets
Category:
C# Syntax
Author:
Rekha
Member Level:
Gold
Rating:
Points
: 10
make a reference to the following Namespace
//namespace imports
using System.Security.Principal;
///
/// method for checking to see if the logged in user
/// is in the Administrator's group
///
///
public bool IsUserAdministrator()
{
//bool value to hold our return value
bool isAdmin;
try
{
//get the currently logged in user
WindowsIdentity user = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(user);
isAdmin = principal.IsInRole(WindowsBuiltInRole.Administrator);
}
catch (UnauthorizedAccessException ex)
{
isAdmin = false;
MessageBox.Show(ex.Message);
}
catch (Exception ex)
{
isAdmin = false;
MessageBox.Show(ex.Message);
}
return isAdmin;
}
Responses
No responses found. Be the first to respond and make money from
revenue sharing program
.
Feedbacks
Popular Tags
What are tags ?
Search Tags
Sign In
(No tags found.)
Post Feedback
This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must
Sign In
to post a response.
Next Resource:
Gridview row color change and opening a page against the click on the row
Previous Resource:
Upload Videos in a ASP.NET page
Return to Discussion Resource Index
Post New Resource
Category:
C# Syntax
Post resources and
earn money
!
Related Resources
Dynamic creation of textboxes
convert a string to a byte array
Connect to Excel as data source
How to get IP Address
Logout - Back Problem
dotNet Slackers
BizTalk Adaptors
Web Design
Contact Us
Privacy Policy
Terms Of Use