Reputation: 51719
How to tell if the current user is an IIS Manager or a Server Administrator?
We have installers that fail at the end of an Add/Remove because the user doesn't have sufficient prividgles to create or delete virtual directories.
Before getting into the meat and potatoes of the install/uninstall operation, is there anyway to check can the user create or delete cirtual directories.
Is there a Permissions Directory we can look up and check for the current user, or something similar?
Thanks
BW
Upvotes: 0
Views: 249
Reputation: 51719
I found this on Code Project, and it does what I need.
The crux of it is the System.IO.FileInfo.GetAccessControl().GetAccessRules
method to get the ACL for the folder.
Snippet
System.IO.FileInfo fi = new System.IO.FileInfo(_path);
AuthorizationRuleCollection acl = fi.GetAccessControl().GetAccessRules(true, true, typeof(SecurityIdentifier));
for (int i = 0; i < acl.Count; i++) {
System.Security.AccessControl.FileSystemAccessRule rule = (System.Security.AccessControl.FileSystemAccessRule)acl[i];
if (_principal.User.Equals(rule.IdentityReference)) {
if (System.Security.AccessControl.AccessControlType.Deny.Equals. (rule.AccessControlType)) {
if (contains(FileSystemRights.AppendData,rule))
_denyAppendData = true;
Upvotes: 1
Reputation: 4277
If the user is added to '' group, he has access to create virtual directory in IIS
if (IISversion == 6)
IIS_WPG - check for user in this group
else
IIS_IUSRS - check for user in this group
Upvotes: 0
Reputation: 769
You'd need to check the ACL on the folder to see if they have permissions or not. You could basically use something like this to grab the path:
Then check the ACL.
Bail on the install if they don't have it.
Upvotes: 0