Login filter - MSSQL

This filter is an easy way to filter login packets -- it's essentially a JavaScript request filter preset with Packet types=Login7.

Parameters

  • Client IPs: optional. If specified, a comma-separated (or line break separated) list of IP4 or IP6 addresses or regular expressions for IP addresses. This filter will then be invoked only for login attempts from the specified IP address(es).

  • Users: optional. If specified, a comma-separated (or line break separated) list of user names or regular expressions for user names. This filter will then be invoked only for login attempts from the specified users. Important: this does not work for Windows logins because we don't know the user name at login time. If you want this functionality for Windows logins, you can set up a JavaScript request filter that rejects certain requests and closes the connection (see the documentation for the result object).


The context.packet object will be a Login7 packet.


Example

A simple-minded login filter that rejects logins from an application called "BadApp" on Sundays:

if (new Date().getDay() === 0) { // 0 == Sunday, 1 == Monday, etc...
if (context.packet.appName === 'BadApp') {
context.result.success = false;
context.result.errorMessage = "You can't log in on Sunday";
context.result.errorCode = 12345;
log.debug("Rejecting login from BadApp because it's Sunday");
}
}