/// <summary>Initializes a new instance of the <see cref="T:System.Security.Principal.WindowsIdentity" /> class for the user represented by the specified User Principal Name (UPN) and the specified authentication type.</summary>
        /// <param name="sUserPrincipalName">The UPN for the user on whose behalf the code is running. </param>
        /// <param name="type">(Informational) The type of authentication used to identify the user. </param>
        /// <exception cref="T:System.UnauthorizedAccessException">Windows returned the Windows NT status code STATUS_ACCESS_DENIED.</exception>
        /// <exception cref="T:System.OutOfMemoryException">There is insufficient memory available.</exception>
        /// <exception cref="T:System.Security.SecurityException">The caller does not have the correct permissions. </exception>
        public WindowsIdentity(string sUserPrincipalName, string type)
        {
            if (sUserPrincipalName == null)
            {
                throw new NullReferenceException("sUserPrincipalName");
            }
            IntPtr userToken = WindowsIdentity.GetUserToken(sUserPrincipalName);

            if (!WindowsIdentity.IsPosix && userToken == IntPtr.Zero)
            {
                throw new ArgumentException("only for Windows Server 2003 +");
            }
            this._authenticated = true;
            this._account       = WindowsAccountType.Normal;
            this._type          = type;
            this.SetToken(userToken);
        }