Difference between revisions of "Documentation/DevGuide/Database/Group Service"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (Robot: Changing Category:Database Access)
 
(2 intermediate revisions by one other user not shown)
Line 6: Line 6:
 
|NextPage=Documentation/DevGuide/Database/User Service
 
|NextPage=Documentation/DevGuide/Database/User Service
 
}}
 
}}
{{DISPLAYTITLE:Group Service}}
+
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Database/{{SUBPAGENAME}}}}
 +
{{DISPLAYTITLE:Group Service}}
 
The service <idl>com.sun.star.sdbcx.Group</idl> is the first of the two security services, <code>Group</code> and <code>User</code>. The <code>Group</code> service represents the group account that has access permissions to a secured database and it has a <code>Name</code> property to identify it. It supports the interface <idl>com.sun.star.sdbcx.XAuthorizable</idl> that allows current privilege settings to be obtained, and to grant or revoke privileges. The second interface is the <idl>com.sun.star.sdbcx.XUsersSupplier</idl>. 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.
 
The service <idl>com.sun.star.sdbcx.Group</idl> is the first of the two security services, <code>Group</code> and <code>User</code>. The <code>Group</code> service represents the group account that has access permissions to a secured database and it has a <code>Name</code> property to identify it. It supports the interface <idl>com.sun.star.sdbcx.XAuthorizable</idl> that allows current privilege settings to be obtained, and to grant or revoke privileges. The second interface is the <idl>com.sun.star.sdbcx.XUsersSupplier</idl>. 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.
  
Line 12: 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 42: Line 43:
 
       }
 
       }
 
   }
 
   }
 
+
</syntaxhighlight>
  
 
{{PDL1}}
 
{{PDL1}}
  
[[Category:Documentation/Developers 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.

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).
Personal tools
In other languages