Quick Start (Base64): Managing access control lists using the web service API

The following C# code example reads and creates access control lists (ACLs) in the LiveCycle repository.

/* 
    * Ensure that you create a .NET client assembly that uses  
    * base64 encoding. This is required to populate a BLOB  
    * object with data or retrieve data from a BLOB object. 
    *  
    * For information, see "Invoking LiveCycle using Base64 Encoding"  
    * in Programming with LiveCycle 
    */ 
using System; 
using System.Collections; 
using System.ComponentModel; 
using System.Data; 
using System.IO; 
 
namespace RepositoryWebService 
{ 
       class UseACL 
       { 
           [STAThread] 
           static void Main(string[] args) 
           { 
               // This example will read and create access control lists for resources in the LiveCycle repository. 
               try 
               { 
                   //Create a RepositoryServiceService object 
                   RepositoryServiceService repositoryClient = new RepositoryServiceService(); 
                   repositoryClient.Credentials = new System.Net.NetworkCredential("administrator", "password"); 
 
                    // Specify the URI of the resource to be used 
                String resourceUri = "/Applications/FormsApplication"; 
 
                   // Retrieve the access control list for the resource 
                   AccessControlList acl = repositoryClient.readAccessControlList(resourceUri, null); 
 
                   // Retrieve a list of the users having access permissions 
                   object[] users = acl.usersWithPermissions; 
 
                   // Print out the list of users 
                   Console.WriteLine("The following users have permissions:"); 
                   for (int i = 0; i < users.Length; i++) 
                   { 
                       String user = (String)(users[i]); 
                       Console.WriteLine("User identifier: " + user); 
                   } 
 
                   // Set up a new access control list 
                   acl = new AccessControlList(); 
 
                   // Create traversal permissions for the folder 
                   object[] permissions = new object[2]; 
                   permissions[0] = "Traverse"; 
                   permissions[1] = "Read"; 
                   AccessControlEntry aclEntry = new AccessControlEntry(); 
                   aclEntry.permissions = permissions; 
                   object[] entries = new object[1]; 
                   entries[0] = aclEntry; 
                   acl.entries = entries; 
 
                   // Set the user who will have access 
                   Object[] usersWithPermissions = new object[1]; 
                   usersWithPermissions[0] = users[0]; 
                   acl.usersWithPermissions = usersWithPermissions; 
 
                   // Set the access control list for the folder 
                   repositoryClient.writeAccessControlList(resourceUri, acl, true, 0,true, null); 
 
               } 
               catch (Exception e) 
               { 
                   Console.WriteLine( 
                       "Exception thrown while trying to manage access control lists" + 
                       e.Message 
                   ); 
               } 
 
           } 
       } 
} 

// Ethnio survey code removed