//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.BuildTasks { using System.Security.Principal; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; public class CheckAdminRights : Task { /// /// Gets or sets a value indicating whether this process has elevated permissions. /// [Output] public bool IsElevated { get; set; } /// /// Executes this instance. /// public override bool Execute() { WindowsIdentity id = WindowsIdentity.GetCurrent(); WindowsPrincipal p = new WindowsPrincipal(id); this.IsElevated = p.IsInRole(WindowsBuiltInRole.Administrator); return true; } } }