I have a code which is working in DEV but not UAT.

I am unable to retrieve the list of users who are granted permission to the folders, which are the users from the following:

Site Contents > List > Locate record (Folder Content Type) 3 dots > Advanced > Shared With

Below is my code:


Log("folder.Item.RoleAssignments = " + folder.Item.RoleAssignments);

node.Attributes.Add("access", GetAccessXml(folder.Item.RoleAssignments, out originalAccess));

Log("originalAccess = " + originalAccess);


private string GetAccessXml(SPRoleAssignmentCollection roleAssignments, out string originalAccess)
    var list = roleAssignments.GetUserWithReadPermissionOnly();

    Log("list = " + list.ToString());

    var entries = "<Entities Append=\"False\" Error=\"\" Separator=\";\" MaxHeight=\"3\">{0}</Entities>";
    var entryTemplate = "<Entity Key=\"{0}\" DisplayText=\"{1}\" IsResolved=\"True\" Description=\"{0}\"><MultipleMatches /></Entity>";
    var entryBuilder = new StringBuilder();
    var csv = new StringBuilder();

    //LOG FILES shows that this loop was not entered <<============
    foreach (var principal in list)
        Log("principal.Name = " + principal.Name);

        var entry = entryTemplate;
        entryBuilder.AppendFormat(entry, principal.LoginName, principal.Name);
    originalAccess = csv.ToString().TrimEnd(',');
    return entries.FormatWith(entryBuilder);

Logs generated:

- folder.Item.RoleAssignments = Microsoft.SharePoint.SPRoleAssignmentCollection
- list = System.Collections.Generic.List`1[Microsoft.SharePoint.SPPrincipal]
- originalAccess = 

Log files shows that inGetAccessXml method, my list variable is empty.

May I know how can I troubleshoot this issue, considering that DEV environment is working, but UAT is not? Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.