Kbase P42900: How to create database users from 4GL
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/16/2008 |
|
Status: Unverified
GOAL:
How to create database users from 4GL
FIX:
The below example prompts for UserId, User name, password and if the new user is an administrator one or not.
DEFINE VARIABLE cUserList AS CHARACTER LABEL "New User: " FORMAT "x(15)" VIEW-AS FILL-IN.
DEFINE VARIABLE cAdminList AS CHARACTER LABEL "New User: " FORMAT "x(15)" VIEW-AS FILL-IN.
DEFINE VARIABLE cUser AS CHARACTER LABEL "New User: " FORMAT "x(65)".
DEFINE VARIABLE cUserPassword AS CHARACTER LABEL "User Password: " FORMAT "x(60)".
DEFINE VARIABLE lAdministrator AS LOGICAL LABEL "Admin : Press F2 to accept, ESC to cancel " VIEW-AS TOGGLE-BOX .
DEFINE VARIABLE cUserName AS CHARACTER LABEL "User Name: " FORMAT "x(60)".
STATUS INPUT "UserList: " .
FIND dictdb._File "_User".
cAdminList = dictdb._File._Can-create.
FOR EACH dictdb._User:
cUserList = (IF cUserList = '' THEN ',' ELSE '') + cUserList + ',' + dictdb._User._UserId.
END.
/*display in the status bar the actual user list */
STATUS INPUT 'User list: ' + cUserList.
/*read one by one the new users and create them*/
REPEAT TRANSACTION:
SET cUser WITH FRAME dbname-frame SIDE-LABELS.
SET cUserName WITH FRAME dbname-frame SIDE-LABELS.
SET cUserPassword WITH FRAME dbname-frame SIDE-LABELS.
SET lAdministrator WITH FRAME dbname-frame SIDE-LABELS.
CREATE dictdb._user.
ASSIGN
dictdb._User._UserId = cUser
dictdb._User._Password = encode(cUserPassword)
dictdb._User._User-Name = cUserName
.
cUserList = (IF cUserList = '' THEN ',' ELSE '') + cUserList + ',' + cUser.
STATUS INPUT "User list: " + cUserList.
IF lAdministrator THEN DO:
cAdminList = (IF cAdminList = '' THEN ',' ELSE '') + cAdminList + ',' + cUser.
MESSAGE cAdminList
VIEW-AS ALERT-BOX INFO BUTTONS OK.
FIND dictdb._File "_File".
FIND dictdb._Field "_Can-read" OF dictdb._File.
dictdb._Field._Can-write = cAdminList.
FIND dictdb._Field "_Can-write" OF dictdb._File.
dictdb._Field._Can-write = cAdminList.
FIND dictdb._Field "_Can-create" OF dictdb._File.
dictdb._Field._Can-write = cAdminList.
FIND dictdb._Field "_Can-delete" OF dictdb._File.
dictdb._Field._Can-write = cAdminList.
FIND dictdb._File "_Field".
FIND dictdb._Field "_Can-read" OF dictdb._File.
dictdb._Field._Can-write = cAdminList.
FIND dictdb._Field "_Can-write" OF dictdb._File.
dictdb._Field._Can-write = cAdminList.
FIND dictdb._File "_User".
ASSIGN
dictdb._File._Can-create = cAdminList
dictdb._File._Can-delete = cAdminList.
END.
END.