/// <summary> /// Validates application user access rights to execute the function. /// </summary> /// <param name="type">The access type being validated.</param> /// <param name="loginId">The login ID of application user making the request.</param> /// <param name="database">The name of the database on which policy is being validated on.</param> /// <param name="noException"> /// If this is switched off, UnauthorizedException is not thrown even when the caller does not /// have access rights to this function. /// </param> public async Task ValidateAsync(AccessTypeEnum type, long loginId, string database, bool noException) { var policy = new PolicyValidator { ObjectNamespace = this._ObjectNamespace, ObjectName = this._ObjectName, LoginId = loginId, Database = database, AccessType = type }; await policy.ValidateAsync().ConfigureAwait(false); this.HasAccess = policy.HasAccess; this.Validated = true; if (this.HasAccess) { return; } if (!noException) { throw new UnauthorizedException("Access is denied."); } }
/// <summary> /// Validates application user access rights to execute the function. /// </summary> /// <param name="type">The access type being validated.</param> /// <param name="loginId">The login ID of application user making the request.</param> /// <param name="database">The name of the database on which policy is being validated on.</param> /// <param name="noException"> /// If this is switched off, UnauthorizedException is not thrown even when the caller does not /// have access rights to this function. /// </param> public async Task ValidateAsync(AccessTypeEnum type, long loginId, string database, bool noException) { var policy = new PolicyValidator { ObjectNamespace = this._ObjectNamespace, ObjectName = this._ObjectName, LoginId = loginId, Database = database, AccessType = type }; await policy.ValidateAsync().ConfigureAwait(false); this.HasAccess = policy.HasAccess; this.Validated = true; if(this.HasAccess) { return; } if(!noException) { throw new UnauthorizedException("Access is denied."); } }