Ejemplo n.º 1
0
        /// <summary>
        ///     Checks that the given user is elevated.
        /// </summary>
        /// <param name="identity">
        ///     The identity to check.
        /// </param>
        /// <returns>
        ///     <c>true</c> if the <paramref name="identity" /> is running elevated; <c>false</c> otherwise.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        ///     <paramref name="identity" /> is <c>null</c>.
        /// </exception>
        public static bool IsElevated(this WindowsIdentity identity)
        {
            ValidationUtils.CheckArgumentNotNull(identity, nameof(identity));

            var principal = new WindowsPrincipal(identity);

            return(principal.IsElevated());
        }