Error 321 when changing security in replicated environment

Error 321 when changing security in replicated environment

Anonymous
Not applicable
672 Views
2 Replies
Message 1 of 3

Error 321 when changing security in replicated environment

Anonymous
Not applicable

Hi there,

 

Error 321 WorkgroupDoesNotHaveAdminOwnership

 

Scenario description:

The file was checked in from another workgroup by a user that was logged on to a subscriber in a replicated environment

 

We need to change File security (Read/Write/Dete) based on assigned parent Folder Security by Vault extension. this extension is logged on to the publisher server. So user has no ownership on the file at this moment.

 

 

I am aware of replication specific issues,still cannot change file security using a vault extension logged on as user on publisher Vault server. We still get exception 321 (WorkgroupDoesNotHaveAdminOwnership ,see red text in my C# Code) when adding new ACL.

 

We can solve this issue manualy by RightMouseClick the file in Vault and update the lease period for a new 5 minutes.

How do we manage this manual procedure using Vault SDK?

 

Thanks in Advance

best regards,

Martijn van Giels

 

 

 

public Boolean SetOverrideSecurity(long FileMasterID)

{

try

{

EntOwn[] ownerhips = _mgr.ReplicationService.GetOwnershipByEntityId(new long[]{FileMasterID});

LongArray group = new LongArray();

 

 

group.Items = new long[] { FileMasterID };

Wkgrp[] _grps = _mgr.ReplicationService.GetAllWorkgroups();

XferStatus[] status = _mgr.ReplicationService.TransferEntityGroupOwnership(_mgr.ReplicationService.GetLocalWorkgroup().Id, new LongArray[] { group }, 1);

if (status.Any(n => !n.IsSuccess))

System.Windows.Forms.MessageBox.Show("One or more ownership transfers failed");

else

System.Windows.Forms.MessageBox.Show("Ownership transfers succeeded");

 

// check the ownership. Give up after 120 seconds.

for (int i = 0; i < 12; i++)

{

ownerhips = _mgr.ReplicationService.GetOwnershipByEntityId(new long[] { FileMasterID });

if (!ownerhips[0].IsLocalOwn)

System.Threading.Thread.Sleep(10000);

else

break;

}

if (!ownerhips[0].IsLocalOwn)

System.Windows.Forms.MessageBox.Show("Timeout expired");

else

System.Windows.Forms.MessageBox.Show("Transfer complete");

 

ADSK.DbOwn ownership = _mgr.ReplicationService.GetDatabaseOwnership(DatabaseType.KnowledgeMaster);

if (!ownership.IsLocalOwn)

{

_mgr.AutoTransferOwnership = true;

ADSK.Wkgrp workgr = _mgr.ReplicationService.GetLocalWorkgroup();

_mgr.ReplicationService.TransferDatabaseOwnership(DatabaseType.KnowledgeMaster, workgr.Id, 1);

}

int x = 0;

while (x < 60 && !_mgr.ReplicationService.GetDatabaseOwnership(DatabaseType.KnowledgeMaster).IsLocalOwn)

{

 

System.Threading.Thread.Sleep(2000);

x++;

}

if (x > 59)

{

System.Windows.Forms.MessageBox.Show("Ownership from Master Vault in Amsterdam could not be retrieved" + Environment.NewLine + "Override security canceled");

return false;

}

Folder[] fldrArray = _mgr.DocumentService.GetFoldersByFileMasterId(FileMasterID);

Folder myFolder = fldrArray[0];

//string[] folders = myFolder.FullName.Split(new char[] { '/' });

//Folder PublishRootfld = _mgr.DocumentService.GetFolderByPath(folders[0] + "/" + folders[1] + "/" + folders[2] + @"/" + folders[3]);

 

ACL[] AcceesCtrList = _mgr.SecurityService.GetACLsByEntityIds(new long[] { myFolder.Id });

ACE[] entries = AcceesCtrList[0].ACEArray;

 

if (entries == null) return false; ;

foreach (ACE ent in entries )

{

long userid = ent.UserGrpId ;

if (UserHasAdminRole(userid)) continue;

//if(ent.PermisArray.Length > 0)ent.PermisArray[0].Val = false;

if (ent.PermisArray.Length > 1) ent.PermisArray[1].Val = false;

if (ent.PermisArray.Length > 2) ent.PermisArray[2].Val = false;

}

ACL myAcl = _mgr.SecurityService.AddSystemACL(entries);

_mgr.SecurityService.SetSystemACLs(new long[] { FileMasterID }, myAcl.Id);

return true;

}

catch (Exception ee)

{

System.Windows.Forms.MessageBox.Show(ee.Message + Environment.NewLine + ee.StackTrace);

return false; }

}

 

 

 

 

 

 

0 Likes
Accepted solutions (1)
673 Views
2 Replies
Replies (2)
Message 2 of 3

minkd
Alumni
Alumni
Accepted solution

It looks like you are getting database ownership of the KnowledgeVaultMaster rather than the Vault you are adding the system ACL to. Try getting database ownership of the Vault instead of the KnowledgeMaster.

 

-Dave

 



Dave Mink
Fusion Lifecycle
Autodesk, Inc.
Message 3 of 3

Anonymous
Not applicable
Thanks for your help. This solved my issue
0 Likes