To manipulate object security, use the IACL interface in the IDK.
Java
publicstatic void updateACL(IObjectManager objectManager, int objectID)
throws PortalException, MalformedURLException, RemoteException
{
IACL acl = objectManager.queryACL(objectID);
// Remove user with ID 101 from the ACL - will be ignored if the user is not present
acl.removeUserEntry(101);
// Add user with ID 10 to the ACL with Admin access
acl.addUserGroupEntry(10, AccessLevel.ADMIN);
//store changes to the portal
objectManager.updateACL(objectID, acl);
IACLEntry[] entries = acl.entries();
for(int i = 0; i < entries.length; i++)
{
if(entries[i].getAccessLevel().equals(AccessLevel.ADMIN))
System.out.println(
entries[i].getPrincipalObjectClass() + " with ID " +
entries[i].getPrincipalID() + " has admin access");
}
}
.NET (C#)
publicstatic void UpdateACL(IObjectManager objectManager, int objectID)
{
IACL acl = objectManager.QueryACL(objectID);
// Remove user with ID 101 from the ACL - will be ignored if the user is not present
acl.RemoveUserEntry(101);
// Add user with ID 10 to the ACL with Admin access
acl.AddUserGroupEntry(10, AccessLevel.ADMIN);
//store changes to the portal
objectManager.UpdateACL(objectID, acl);
IACLEntry[] entries = acl.Entries();
for(int i = 0; i < entries.Length; i++)
{
if(entries[i].GetAccessLevel().equals(AccessLevel.ADMIN))
Console.WriteLine(
entries[i].GetPrincipalObjectClass() + " with ID " +
entries[i].GetPrincipalID() + " has admin access");
}
}
.NET (VB)
PublicShared Sub UpdateACL(ByVal objectManager As IObjectManager, ByVal objectID As Integer) Dim acl As IACL = objectManager.QueryACL(objectID) ' Remove user with ID 101 from the ACL - will be ignored if the user is not present acl.RemoveUserEntry(101) ' Add user with ID 10 to the ACL with Edit access acl.AddUserGroupEntry(10, AccessLevel.EDIT) ' store changes to the portal objectManager.UpdateACL(objectID, acl) Dim entries() As IACLEntry = acl.Entries() Dim i As Integer For i = 0 To entries.Length If entries(i).GetAccessLevel() Is AccessLevel.ADMIN Then Console.WriteLine( _ entries(i).GetPrincipalObjectClass() & " with ID " & _ entries(i).GetPrincipalID() & " has admin access") End If Next i EndSub