blob: c63ac111fe1bffa3a724838fae03640a2b564fc1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
//-----------------------------------------------------------------------
// <copyright file="CheckAdminRights.cs" company="Outercurve Foundation">
// Copyright (c) Outercurve Foundation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.BuildTasks {
using System.Security.Principal;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
public class CheckAdminRights : Task {
/// <summary>
/// Gets or sets a value indicating whether this process has elevated permissions.
/// </summary>
[Output]
public bool IsElevated { get; set; }
/// <summary>
/// Executes this instance.
/// </summary>
public override bool Execute() {
WindowsIdentity id = WindowsIdentity.GetCurrent();
WindowsPrincipal p = new WindowsPrincipal(id);
this.IsElevated = p.IsInRole(WindowsBuiltInRole.Administrator);
return true;
}
}
}
|