CAN-DO ( id-pattern-list , userid )Table 10 lists some basic user ID patterns that you can include in id-pattern-list, where user-ID can be a fully qualified or non-qualified user ID, depending on your application and authentication design, and string is a sequence of characters from any user ID. For more information on fully qualified and non-qualified user ID’s, see the reference entries for the QUALIFIED-USER-ID attribute, USER-ID attribute, and USERID function.
!user-ID Users whose IDs begin with string have access. !string* Users whose IDs begin with string do not have access.You can use any combination of patterns to define id-pattern-list. These patterns are fully consistent with the permissions that you can define for OpenEdge database tables and fields using database administration tools.Table 11 shows some examples of fully qualified user ID matches.
Table 11: The "mark" user name in the blank domain All user names that begin with "mark" in the blank domain All user names that end with "jones" in the blank domain The blank user name in the "acme" domain All user names in the "acme" domain The "mark" user name in any domain
Note: For a more complete description of the possible patterns and their meanings, see OpenEdge Getting Started: Identity Management and the Database Administration online help.A character expression that evaluates to a user ID value that can be returned from the QUALIFIED-USER-ID attribute, USER-ID attribute, or USERID function. The userid is checked against id-pattern-list. If you do not enter userid, the compiler inserts the USERID function by default, which is evaluated each time you run the procedure or class. If the compiler inserts the USERID function, the function does not reference a database name and therefore only works for an ABL session with one database connection. If you explicitly use the USERID function and have more than one database connected, be sure to include the database name with the function call, for example, USERID("sports2000").The r-cando.p procedure is based on an activity permission table called permission. This permission table is not included in any of the installed sample databases. However, the records in this table contain two fields and might look something like the following:
In r-cando.p the FIND statement reads the record for the activity "custedit" in the permission table. The CAN-DO function compares the value of USERID (the user ID of the single session database connection) with the list of users in the Can-Run field of the custedit record. If the user ID is "manager" or "salesrep", the procedure continues executing. Otherwise, the procedure displays a message and control returns to the calling procedure.
DO FOR permission:FIND permission WHERE Activity = "custedit".IF NOT CAN-DO(permission.Can-Run, USERID) THEN DO:MESSAGE "You are not authorized to run this procedure".RETURN.END.END.In this next example, the CAN-DO function compares the value of USERID against the list of user ID patterns passed as a constant string to the function. The values in the constant string include "manager" and any user IDs beginning with "acctg" except "acctg8". If there is no match between the two values, the procedure displays a message and then exits.
IF NOT CAN-DO("manager,!acctg8,acctg@*", USERID) THEN DO:MESSAGE "You are not authorized to run this procedure.".RETURN.END.
If id-pattern-list contains contradictory values, the first occurrence of a value in the list applies. For example, CAN-DO("abc,!abc*") evaluates to TRUE, because the user ID, "abc", appears before "!abc" in id-pattern-list.
If id-pattern-list is exhausted without a match, CAN-DO returns a value of FALSE. Therefore, "!abc" restricts "abc" and everyone else, including the blank user ID (""). To restrict "abc" only and allow everyone else, use "!abc,*".
If a user is logged into a UNIX system as root, the AVM allows access to the procedure even if access is denied by the id-pattern-list. You must specifically deny root access by adding "!root" to the id-pattern-list.
In addition to the examples shown above, you can use the CAN-DO function to compare a userid other than that of the current user against the list of values in id-pattern-list. For example, to assign a department userid to users "smith" and "jones" when they start the ABL session, you can prompt these users for a department userid and password and check them against a table of department ID’s.
You can use the CAN-DO function to match a user ID against run-time table and field permissions stored in an OpenEdge RDBMS by accessing the user ID patterns stored in the _Can-* fields of the _File metaschema table.
ABL raises an error if you omit userid and one of the following conditions exists:
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates. |