You are viewing limited content. For full access, please sign in.

Question

Question

Detect all folders where the "Inherit rights..." checkbox was removed within a repository

asked on September 16, 2015

Hi,

 

I need to modify the security setting in a repository where many folders were set not to Inherit from parent path.  There's just too many to do it manually.

 

Is there a script that I can use, that will list all entries where that security Inerhitance is broken?  Then I could write a Workflow to add additional security entries to each of these folders.

 

Any SDK scripting examples? or other method?
 

0 0

Replies

replied on September 16, 2015 Show version history

Here is a script using the .NET SDK (RepositoryAccess):

static void Main(string[] args)
{
    try
    {
        string server = ""; // server name here
        string repository = ""; // repository name here
        string username = ""; // username here
        string password = ""; // password here

        RepositoryRegistration rr = new RepositoryRegistration(server, repository);

        using (Session session = new Session())
        {
            session.LogIn(username, password, rr);

            Queue<FolderInfo> folders = new Queue<FolderInfo>();
            folders.Enqueue(Folder.GetFolderInfo(1, session));

            // crawl all folders in the repository
            while (folders.Count > 0)
            {
                FolderInfo folder = folders.Dequeue();

                List<int> childIds = new List<int>();
                EntryListingSettings settings = new EntryListingSettings();
                settings.AddColumn(SystemColumn.Id);
                using (FolderListing listing = folder.OpenFolderListing(settings))
                {
                    foreach (var row in listing)
                        childIds.Add((int)row[SystemColumn.Id]);
                }

                foreach (int id in childIds)
                {
                    EntryInfo entry = Entry.GetEntryInfo(id, session);
                    if (entry.GetAccessControl().AreAccessRulesProtected)
                        Console.WriteLine(entry.Path); // Found an entry without inherited security

                    // Add subfolders to the queue of folders to be crawled
                    if (entry.EntryType == EntryType.Folder || entry.EntryType == EntryType.RecordSeries)
                        folders.Enqueue((FolderInfo)entry);
                }
            }
        }
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
    }

 

 

1 0
replied on September 17, 2015 Show version history

Thanks Robert for this.   I have moved this script to a Worklfow SDK Script and modified it for that purpose. Seems to be working great.

 

However, I wanted first to list all folders with Inherit Rights removed so I did created a Script Token and set it at Multi-Value.  I have used the following line to add each Path info to my token but it doesn't seem to behave as a multivalue token.  Only the latest value is set in the token.

this.SetTokenValue("FoldersList", entry.Path);

Any idea why ?

0 0
replied on September 17, 2015
List<object> values = this.WorkflowApi.GetTokenAsMultiValue("MyToken");

values.Add("My new Value");

// set global token, third parameter indicates whether to convert values to string
this.WorkflowApi.SetMultiValueToken("MyToken", values, false);

//set activity token,, third parameter indicates whether to convert values to string
this.WorkflowApi.SetMultiValueActivityToken("MyToken", values, false);

 

1 0
replied on September 17, 2015

Thanks Miruna for this info smiley    Working fine now.

0 0
replied on November 3, 2023

Hi Daniel,

Might I be able to get a copy of the workflow you created for this purpose? We're looking at doing the same thing within our agency.

Thanks,
Michael

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.