4D v14.3On SQL Authentication Database Method |
|||||||||||||||||||
|
4D v14.3
On SQL Authentication Database Method
|
Parameters | Type | Description |
$1 | Text | User name |
$2 | Text | Password |
$3 | Text | (optional) IP address of client at origin of the request |
$0 | Boolean | True = request accepted, False = request refused |
You must declare these parameters as follows:
The password ($2) is received as standard text.
You must check the identifiers of the SQL connection in the On SQL Authentication Database Method. For example, you can check the name and password using a custom table of users. If the identifiers are valid, pass True in $0 to accept the connection. Otherwise, pass False in $0; in this case, the connection is refused.
Note: If the On SQL Authentication Database Method does not exist, the connection is evaluated using the integrated user management system of 4D (if it is activated, in other words, if a password has been assigned to the Designer). If this system is not activated, users are connected with Designer access rights (free access).
If you have passed True in $0, you must then successfully call the CHANGE CURRENT USER command in the On SQL Authentication Database Method in order for the request to be accepted and for 4D to open an SQL session for the user.
The use of the CHANGE CURRENT USER command can be used to implement a virtual authentication system which has the double advantage of allowing the control of connection actions and of hiding the connection identifiers from the outside in the 4D SQL session.
This example of the On SQL Authentication Database Method checks whether the connection request comes from the internal network, validates the identifiers and then assigns access rights to the "sql_user" user for the SQL session.
C_TEXT($1;$2;$3)
C_BOOLEAN($0)
`$1: user
`$2: password
`{$3: IP address of client}
ON ERR CALL("SQL_error")
If(checkInternalIP($3))
`The checkInternalIP method checks whether the IP address is internal
If($1="victor") & ($2="hugo")
CHANGE CURRENT USER("sql_user";"")
If(OK=1)
$0:=True
Else
$0:=False
End if
Else
$0:=False
End if
Else
$0:=False
End if
Product: 4D
Theme: SQL
4D Language Reference ( 4D v12.4)
4D Language Reference ( 4D v11 SQL Release 6)
4D Language Reference ( 4D v14 R3)
4D Language Reference ( 4D v14 R2)
4D Language Reference ( 4D v13.5)
4D Language Reference ( 4D v14.3)
4D Language Reference ( 4D v14 R4)