Difference between revisions of "Documentation/DevGuide/Database/Group Service"
From Apache OpenOffice Wiki
< Documentation | DevGuide
OOoWikiBot (Talk | contribs) m (FINAL VERSION FOR L10N) |
|||
Line 13: | Line 13: | ||
<!--[SOURCE:Database/sdbcx.java]--> | <!--[SOURCE:Database/sdbcx.java]--> | ||
− | + | <syntaxhighlight lang="java"> | |
// print all groups and the users with their privileges who belong to this group | // print all groups and the users with their privileges who belong to this group | ||
public static void printGroups(XTablesSupplier xTabSup) throws com.sun.star.uno.Exception, SQLException { | public static void printGroups(XTablesSupplier xTabSup) throws com.sun.star.uno.Exception, SQLException { | ||
Line 43: | Line 43: | ||
} | } | ||
} | } | ||
− | + | </syntaxhighlight> | |
{{PDL1}} | {{PDL1}} | ||
[[Category:Documentation/Developer's Guide/Database Access]] | [[Category:Documentation/Developer's Guide/Database Access]] |
Latest revision as of 15:11, 21 December 2020
The service com.sun.star.sdbcx.Group is the first of the two security services, Group
and User
. The Group
service represents the group account that has access permissions to a secured database and it has a Name
property to identify it. It supports the interface com.sun.star.sdbcx.XAuthorizable that allows current privilege settings to be obtained, and to grant or revoke privileges. The second interface is the com.sun.star.sdbcx.XUsersSupplier. The word 'Supplier' in the interface name identifies the group object as a container for users. The container returned here is a collection of all users that belong to this group.
// print all groups and the users with their privileges who belong to this group public static void printGroups(XTablesSupplier xTabSup) throws com.sun.star.uno.Exception, SQLException { System.out.println("Example printGroups"); XGroupsSupplier xGroupsSup = (XGroupsSupplier)UnoRuntime.queryInterface( XGroupsSupplier.class, xTabSup); if (xGroupsSup != null) { // the table must be at least support a XColumnsSupplier interface System.out.println("--- Groups ---"); XNameAccess xGroups = xGroupsSup.getGroups(); String [] aGroupNames = xGroups.getElementNames(); for (int i =0; i < aGroupNames.length; i++) { System.out.println(" " + aGroupNames[i]); XUsersSupplier xUsersSup = (XUsersSupplier)UnoRuntime.queryInterface( XUsersSupplier.class, xGroups.getByName(aGroupNames[i])); if (xUsersSup != null) { XAuthorizable xAuth = (XAuthorizable)UnoRuntime.queryInterface( XAuthorizable.class, xUsersSup); // the table must be at least support a XColumnsSupplier interface System.out.println("\t--- Users ---"); XNameAccess xUsers = xUsersSup.getUsers(); String [] aUserNames = xUsers.getElementNames(); for (int j = 0; j < aUserNames.length; j++) { System.out.println("\t " + aUserNames[j] + " Privileges: " + xAuth.getPrivileges(aUserNames[j], PrivilegeObject.TABLE)); } } } } }
Content on this page is licensed under the Public Documentation License (PDL). |