Ejemplo n.º 1
0
        private ReadOnlyMemory <byte> PreAuthFailed(PreAuthenticationContext context)
        {
            var err = new KrbError
            {
                ErrorCode = KerberosErrorCode.KDC_ERR_PREAUTH_FAILED,
                EText     = context.Failure.Message,
                Realm     = this.RealmService.Name,
                SName     = KrbPrincipalName.FromPrincipal(context.Principal)
            };

            err.StampServerTime();

            return(err.EncodeApplication());
        }
Ejemplo n.º 2
0
        private ReadOnlyMemory <byte> RequirePreAuth(PreAuthenticationContext context)
        {
            this.logger.LogTrace("AS-REQ requires pre-auth for user {User}", context.Principal.PrincipalName);

            var err = new KrbError
            {
                ErrorCode = KerberosErrorCode.KDC_ERR_PREAUTH_REQUIRED,
                EText     = string.Empty,
                Realm     = this.RealmService.Name,
                SName     = KrbPrincipalName.FromPrincipal(context.Principal),
                EData     = new KrbMethodData
                {
                    MethodData = context.PaData.ToArray()
                }.Encode()
            };

            err.StampServerTime();

            return(err.EncodeApplication());
        }
Ejemplo n.º 3
0
        internal static ReadOnlyMemory <byte> GenerateError(KerberosErrorCode code, string error, string realm, string sname)
        {
            var krbErr = new KrbError()
            {
                ErrorCode = code,
                EText     = error,
                Realm     = realm,
                SName     = new KrbPrincipalName
                {
                    Type = PrincipalNameType.NT_SRV_INST,
                    Name = new[] {
                        sname,
                        realm
                    }
                }
            };

            krbErr.StampServerTime();

            return(krbErr.EncodeApplication());
        }