Ejemplo n.º 1
0
        internal static bool IsGreaterOrEqual(TokenImpersonationLevel x, TokenImpersonationLevel y)
        {
            TokenImpersonationLevelHelper.Validate(x);
            TokenImpersonationLevelHelper.Validate(y);

            if (x == y)
            {
                return(true);
            }

            int px = 0;
            int py = 0;

            for (int i = 0; i < s_TokenImpersonationLevelOrder.Length; i++)
            {
                if (x == s_TokenImpersonationLevelOrder[i])
                {
                    px = i;
                }
                if (y == s_TokenImpersonationLevelOrder[i])
                {
                    py = i;
                }
            }

            return(px > py);
        }
Ejemplo n.º 2
0
        internal static string AppendWindowsAuthenticationInfo(string inputString, NetworkCredential credential,
                                                               AuthenticationLevel authenticationLevel, TokenImpersonationLevel impersonationLevel)
        {
            const string delimiter = "\0"; // nonprintable characters are invalid for SSPI Domain/UserName/Password

            if (NetworkCredentialHelper.IsDefault(credential))
            {
                string sid = NetworkCredentialHelper.GetCurrentUserIdAsString(credential);
                return(string.Concat(inputString, delimiter,
                                     sid, delimiter,
                                     AuthenticationLevelHelper.ToString(authenticationLevel), delimiter,
                                     TokenImpersonationLevelHelper.ToString(impersonationLevel)));
            }
            return(string.Concat(inputString, delimiter,
                                 credential.Domain, delimiter,
                                 credential.UserName, delimiter,
                                 credential.Password, delimiter,
                                 AuthenticationLevelHelper.ToString(authenticationLevel), delimiter,
                                 TokenImpersonationLevelHelper.ToString(impersonationLevel)));
        }