The examples generate temporary data to illustrate the application of access controls before their removal.
1 Code Block
CAS Action Data
Explanation : This example demonstrates the basic use of 'updSomeAcsTable' to revoke a specific 'Select' permission. It starts by creating a table, explicitly granting 'Select' access to 'groupA', then uses 'updSomeAcsTable' with 'permType="None"' to remove this direct control. The intermediate 'listAcsTable' steps allow visualizing the state of permissions before and after the operation.
Copied!
/* Début de l'exemple 1: Suppression Basique d'un Accès SELECT */
/* Création d'une session CAS */
CAS casauto;
/* Création d'une caslib temporaire pour l'exemple */
CASLIB mycaslib_temp LIBRARY="/tmp/mycaslib_temp" ;
/* Charger des données de démonstration dans une table CAS temporaire */
data casuser.tableA;
input id $ name $;
datalines;
1 John
2 Jane
;
run;
/* Sauvegarder la table en sashdat pour qu'elle puisse avoir des contrôles d'accès directs */
proc casutil incaslib="casuser" outcaslib="mycaslib_temp" ;
save casuser.tableA replace ;
quit;
/* Vérifier les contrôles d'accès existants (normalement aucun direct au début) */
proc cas;
accessControl.listAcsTable /
caslib="mycaslib_temp",
table="tableA.sashdat" ;
quit;
/* Ajouter un contrôle d'accès direct 'Select' pour groupA sur tableA */
proc cas;
accessControl.modAcsTable /
caslib="mycaslib_temp",
table="tableA.sashdat",
identity="groupA",
identityType="Group",
permission="Select",
permType="Grant" ;
quit;
/* Vérifier que le contrôle d'accès direct a été ajouté */
proc cas;
accessControl.listAcsTable /
caslib="mycaslib_temp",
table="tableA.sashdat" ;
quit;
/* Supprimer le contrôle d'accès direct 'Select' pour groupA sur tableA */
proc cas;
accessControl.updSomeAcsTable /
acs={
{caslib="mycaslib_temp",
table="tableA.sashdat",
identity="groupA",
identityType="Group",
permType="None",
permission="Select"}
};
quit;
/* Vérifier que le contrôle d'accès direct a été supprimé */
proc cas;
accessControl.listAcsTable /
caslib="mycaslib_temp",
table="tableA.sashdat" ;
quit;
/* Nettoyer: Supprimer la table CAS et la caslib temporaire */
proc casutil incaslib="mycaslib_temp" ;
drop tableA ;
quit;
CASLIB mycaslib_temp DROP ;
CAS;
/* Fin de l'exemple 1 */
1
/* Début de l'exemple 1: Suppression Basique d'un Accès SELECT */
2
3
/* Création d'une session CAS */
4
CAS casauto;
5
6
/* Création d'une caslib temporaire pour l'exemple */
/* Vérifier les contrôles d'accès existants (normalement aucun direct au début) */
24
PROC CAS;
25
ACCESSCONTROL.listAcsTable /
26
caslib="mycaslib_temp",
27
TABLE="tableA.sashdat" ;
28
QUIT;
29
30
/* Ajouter un contrôle d'accès direct 'Select' pour groupA sur tableA */
31
PROC CAS;
32
ACCESSCONTROL.modAcsTable /
33
caslib="mycaslib_temp",
34
TABLE="tableA.sashdat",
35
identity="groupA",
36
identityType="Group",
37
permission="Select",
38
permType="Grant" ;
39
QUIT;
40
41
/* Vérifier que le contrôle d'accès direct a été ajouté */
42
PROC CAS;
43
ACCESSCONTROL.listAcsTable /
44
caslib="mycaslib_temp",
45
TABLE="tableA.sashdat" ;
46
QUIT;
47
48
/* Supprimer le contrôle d'accès direct 'Select' pour groupA sur tableA */
49
PROC CAS;
50
ACCESSCONTROL.updSomeAcsTable /
51
acs={
52
{caslib="mycaslib_temp",
53
TABLE="tableA.sashdat",
54
identity="groupA",
55
identityType="Group",
56
permType="None",
57
permission="Select"}
58
};
59
QUIT;
60
61
/* Vérifier que le contrôle d'accès direct a été supprimé */
62
PROC CAS;
63
ACCESSCONTROL.listAcsTable /
64
caslib="mycaslib_temp",
65
TABLE="tableA.sashdat" ;
66
QUIT;
67
68
/* Nettoyer: Supprimer la table CAS et la caslib temporaire */
69
PROC CASUTIL incaslib="mycaslib_temp" ;
70
drop tableA ;
71
QUIT;
72
CASLIB mycaslib_temp DROP ;
73
CAS;
74
/* Fin de l'exemple 1 */
2 Code Block
CAS Action Data
Explanation : This example illustrates how to remove multiple direct access permissions ('Read' and 'Write') for a user ('userX') on a specific table ('tableB.sashdat') in a single 'updSomeAcsTable' execution. The syntax uses an 'acs' array to include multiple permission objects, each specifying 'permType="None"'.
Copied!
/* Début de l'exemple 2: Suppression de Multiples Permissions pour un Utilisateur */
CAS casauto;
CASLIB mycaslib_temp2 LIBRARY="/tmp/mycaslib_temp2";
data casuser.tableB;
input id $ value;
datalines;
A 10
B 20
;
run;
proc casutil incaslib="casuser" outcaslib="mycaslib_temp2";
save casuser.tableB replace;
quit;
/* Accorder des permissions 'Read' et 'Write' directes à 'userX' sur 'tableB' */
proc cas;
accessControl.modAcsTable /
caslib="mycaslib_temp2",
table="tableB.sashdat",
identity="userX",
identityType="User",
permission="Read",
permType="Grant";
accessControl.modAcsTable /
caslib="mycaslib_temp2",
table="tableB.sashdat",
identity="userX",
identityType="User",
permission="Write",
permType="Grant";
quit;
/* Lister les ACLs pour vérifier */
proc cas;
accessControl.listAcsTable /
caslib="mycaslib_temp2",
table="tableB.sashdat";
quit;
/* Supprimer les contrôles d'accès directs 'Read' et 'Write' pour 'userX' */
proc cas;
accessControl.updSomeAcsTable /
acs={
{caslib="mycaslib_temp2",
table="tableB.sashdat",
identity="userX",
identityType="User",
permType="None",
permission="Read"},
{caslib="mycaslib_temp2",
table="tableB.sashdat",
identity="userX",
identityType="User",
permType="None",
permission="Write"}
};
quit;
/* Lister les ACLs pour vérifier la suppression */
proc cas;
accessControl.listAcsTable /
caslib="mycaslib_temp2",
table="tableB.sashdat";
quit;
/* Nettoyer: Supprimer la table CAS et la caslib temporaire */
proc casutil incaslib="mycaslib_temp2" ;
drop tableB ;
quit;
CASLIB mycaslib_temp2 DROP ;
CAS;
/* Fin de l'exemple 2 */
1
/* Début de l'exemple 2: Suppression de Multiples Permissions pour un Utilisateur */
/* Accorder des permissions 'Read' et 'Write' directes à 'userX' sur 'tableB' */
19
PROC CAS;
20
ACCESSCONTROL.modAcsTable /
21
caslib="mycaslib_temp2",
22
TABLE="tableB.sashdat",
23
identity="userX",
24
identityType="User",
25
permission="Read",
26
permType="Grant";
27
ACCESSCONTROL.modAcsTable /
28
caslib="mycaslib_temp2",
29
TABLE="tableB.sashdat",
30
identity="userX",
31
identityType="User",
32
permission="Write",
33
permType="Grant";
34
QUIT;
35
36
/* Lister les ACLs pour vérifier */
37
PROC CAS;
38
ACCESSCONTROL.listAcsTable /
39
caslib="mycaslib_temp2",
40
TABLE="tableB.sashdat";
41
QUIT;
42
43
/* Supprimer les contrôles d'accès directs 'Read' et 'Write' pour 'userX' */
44
PROC CAS;
45
ACCESSCONTROL.updSomeAcsTable /
46
acs={
47
{caslib="mycaslib_temp2",
48
TABLE="tableB.sashdat",
49
identity="userX",
50
identityType="User",
51
permType="None",
52
permission="Read"},
53
{caslib="mycaslib_temp2",
54
TABLE="tableB.sashdat",
55
identity="userX",
56
identityType="User",
57
permType="None",
58
permission="Write"}
59
};
60
QUIT;
61
62
/* Lister les ACLs pour vérifier la suppression */
63
PROC CAS;
64
ACCESSCONTROL.listAcsTable /
65
caslib="mycaslib_temp2",
66
TABLE="tableB.sashdat";
67
QUIT;
68
69
/* Nettoyer: Supprimer la table CAS et la caslib temporaire */
70
PROC CASUTIL incaslib="mycaslib_temp2" ;
71
drop tableB ;
72
QUIT;
73
CASLIB mycaslib_temp2 DROP ;
74
CAS;
75
/* Fin de l'exemple 2 */
3 Code Block
CAS Action / CASL Data
Explanation : This example combines CASL (SAS Cloud Analytic Services Language) with the 'accessControl.updSomeAcsTable' action. A CASL macro is created to first list a table's access controls, check if a specific direct permission ('Delete' for 'userZ') exists, and only if it exists, remove it using 'updSomeAcsTable'. This illustrates a more robust and conditional management of rights.
Copied!
/* Début de l'exemple 3: Suppression Conditionnelle d'Accès et Vérification */
CAS casauto;
CASLIB mycaslib_temp3 LIBRARY="/tmp/mycaslib_temp3";
data casuser.tableC;
input id $ value;
datalines;
X 100
Y 200
;
run;
proc casutil incaslib="casuser" outcaslib="mycaslib_temp3";
save casuser.tableC replace;
quit;
/* Accorder temporairement une permission 'Delete' à 'userZ' */
proc cas;
accessControl.modAcsTable /
caslib="mycaslib_temp3",
table="tableC.sashdat",
identity="userZ",
identityType="User",
permission="Delete",
permType="Grant";
quit;
/* Utiliser CASL pour vérifier si la permission 'Delete' existe avant de la supprimer */
%macro check_and_remove(caslib, table, identity, permission);
proc cas;
outargs=\"acltable\" accessControl.listAcsTable /
caslib=&caslib,
table=&table;
quit;
%local found_direct_delete;
%let found_direct_delete = 0;
%do i = 1 %to &acltable.Acl.nobs;
%if "&acltable.Acl[&i,identity]" = "&identity" and
"&acltable.Acl[&i,permission]" = "&permission" and
"&acltable.Acl[&i,permType]" = "Direct" %then %do;
%let found_direct_delete = 1;
%goto found;
%end;
%end;
%found:
%if &found_direct_delete = 1 %then %do;
%put NOTE: Permission &permission for &identity found. Attempting to remove direct control.;
proc cas;
accessControl.updSomeAcsTable /
acs={
{caslib="&caslib",
table="&table",
identity="&identity",
identityType="User",
permType="None",
permission="&permission"}
};
quit;
%put NOTE: Direct control for &permission for &identity removed.;
%end;
%else %do;
%put NOTE: No direct permission &permission found for &identity.;
%end;
/* Re-lister pour confirmation */
proc cas;
accessControl.listAcsTable /
caslib=&caslib,
table=&table ;
quit;
%mend;
/* Exécuter la macro */
%check_and_remove(mycaslib_temp3, tableC.sashdat, userZ, Delete);
/* Nettoyer: Supprimer la table CAS et la caslib temporaire */
proc casutil incaslib="mycaslib_temp3" ;
drop tableC ;
quit;
CASLIB mycaslib_temp3 DROP ;
CAS;
/* Fin de l'exemple 3 */
1
/* Début de l'exemple 3: Suppression Conditionnelle d'Accès et Vérification */
/* Nettoyer: Supprimer la table CAS et la caslib temporaire */
82
proc casutil incaslib="mycaslib_temp3" ;
83
drop tableC ;
84
quit;
85
CASLIB mycaslib_temp3 DROP ;
86
CAS;
87
/* Fin de l'exemple 3 */
4 Code Block
CAS Action Data
Explanation : This example focuses on managing access controls for transient tables (in-memory CAS). It creates a temporary table, grants direct 'Alter' permission to 'userY', then uses 'updSomeAcsTable' to revoke this permission. This is relevant in Viya/CAS environments where in-memory tables can also have ACLs.
Copied!
/* Début de l'exemple 4: Gestion de l'Accès pour une Table Transitoire (Viya/CAS) */
CAS casauto;
/* Créer une table CAS transitoire (en mémoire, caslib 'casuser' par défaut) */
data casuser.temp_data;
input col1 col2;
datalines;
10 20
30 40
;
run;
/* Accorder un accès 'Alter' direct à un 'userY' sur la table transitoire */
proc cas;
accessControl.modAcsTable /
caslib="casuser",
table="temp_data",
identity="userY",
identityType="User",
permission="Alter",
permType="Grant";
quit;
/* Lister les ACLs pour vérifier */
proc cas;
accessControl.listAcsTable /
caslib="casuser",
table="temp_data";
quit;
/* Supprimer le contrôle d'accès direct 'Alter' pour 'userY' */
proc cas;
accessControl.updSomeAcsTable /
acs={
{caslib="casuser",
table="temp_data",
identity="userY",
identityType="User",
permType="None",
permission="Alter"}
};
quit;
/* Lister les ACLs pour vérifier la suppression */
proc cas;
accessControl.listAcsTable /
caslib="casuser",
table="temp_data";
quit;
/* Nettoyer: Supprimer la table CAS transitoire */
proc casutil incaslib="casuser" ;
drop temp_data ;
quit;
CAS;
/* Fin de l'exemple 4 */
1
/* Début de l'exemple 4: Gestion de l'Accès pour une Table Transitoire (Viya/CAS) */
2
3
CAS casauto;
4
5
/* Créer une table CAS transitoire (en mémoire, caslib 'casuser' par défaut) */
6
DATA casuser.temp_data;
7
INPUT col1 col2;
8
DATALINES;
9
1020
10
3040
11
;
12
RUN;
13
14
/* Accorder un accès 'Alter' direct à un 'userY' sur la table transitoire */
15
PROC CAS;
16
ACCESSCONTROL.modAcsTable /
17
caslib="casuser",
18
TABLE="temp_data",
19
identity="userY",
20
identityType="User",
21
permission="Alter",
22
permType="Grant";
23
QUIT;
24
25
/* Lister les ACLs pour vérifier */
26
PROC CAS;
27
ACCESSCONTROL.listAcsTable /
28
caslib="casuser",
29
TABLE="temp_data";
30
QUIT;
31
32
/* Supprimer le contrôle d'accès direct 'Alter' pour 'userY' */
33
PROC CAS;
34
ACCESSCONTROL.updSomeAcsTable /
35
acs={
36
{caslib="casuser",
37
TABLE="temp_data",
38
identity="userY",
39
identityType="User",
40
permType="None",
41
permission="Alter"}
42
};
43
QUIT;
44
45
/* Lister les ACLs pour vérifier la suppression */
46
PROC CAS;
47
ACCESSCONTROL.listAcsTable /
48
caslib="casuser",
49
TABLE="temp_data";
50
QUIT;
51
52
/* Nettoyer: Supprimer la table CAS transitoire */
53
PROC CASUTIL incaslib="casuser" ;
54
drop temp_data ;
55
QUIT;
56
CAS;
57
/* Fin de l'exemple 4 */
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
« Always run accessControl.listAcsTable before and after using this action. Verifying the state of the ACL ensures that removing a direct control achieves the desired result through inheritance rather than inadvertently leaving a user with no access at all. »
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.