SharePoint 2016 user error when running csom code to write to list RRS feed

  • Question

  • Hello,

    I have some custom CSOM code running on an announcement list, which writes to another list once the user acknowledges. Some users who have contribute access are getting the error "User does not exist or is not unique". If I give these users design, it is working. However, on a another site collection on the same farm this functionality works for the same user.

    Here are he entries from the ULS log for the non working site.. (The username and company values have been modified)

    09/29/2020 16:38:42.64        w3wp.exe (0x1734)        0x597C        SharePoint Foundation        General        8xfr        Medium        PermissionMask check failed for {87230EE1-67DF-4C2D-A0D6-A21CEDE4B080}. Asking for 0x00000100, have 0x1B03C4312EF        39dc7e9f-ba26-50f1-bd67-515421b1c63d






    09/29/2020 16:38:42.64        w3wp.exe (0x1734)        0x597C        SharePoint Foundation        General        aio6i        High        UserInfoList is marked as LSWriteNoItems, access is denied for update.        39dc7e9f-ba26-50f1-bd67-515421b1c63d


    09/29/2020 16:38:42.64        w3wp.exe (0x1734)        0x597C        SharePoint Foundation        Authentication Authorization        atd4d        Medium        Setting status to access denied.        39dc7e9f-ba26-50f1-bd67-515421b1c63d



    09/29/2020 16:38:42.64        w3wp.exe (0x1734)        0x597C        SharePoint Foundation        Authentication Authorization        aio6j        High        Failed to add [Login=i:0#.w|<company>\<username>] to the database. It may already exist at [SiteId=B0509E66-CA9C-4578-AF08-E33A5964318C][UserId=-1]. HR=0x80070005        39dc7e9f-ba26-50f1-bd67-515421b1c63d


    09/29/2020 16:38:42.64        w3wp.exe (0x1734)        0x597C        SharePoint Foundation        General        8kh7        High        The user does not exist or is not unique.        39dc7e9f-ba26-50f1-bd67-515421b1c63d



    • Moved by Dave PatrickMVP Friday, October 2, 2020 2:14 PM looking for forum
    Friday, October 2, 2020 12:55 PM


All replies

  • Add this line context.Load(lib); into your code before context.ExecuteQuery();, compare the results.

    With the Load(lib), it informs the client object model to load the information of SP.List object when the application calls the ExecuteQuery method.

    Here is demo to connect to SharePoint Online and get list/library by title:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.SharePoint.Client;
    using System.Security;

    namespace TestGetFiles
        class Program

            private class Configuration
                public static string ServiceSiteUrl = "https://tenant.sharepoint.com/<site>";
                public static string ServiceUserName = "admin@tenant.onmicrosoft.com";
                public static string ServicePassword = "<password>";

            static ClientContext GetonlineContext()
                var securePassword = new SecureString();
                foreach (char c in Configuration.ServicePassword)
                var onlineCredentials = new SharePointOnlineCredentials(Configuration.ServiceUserName, securePassword);
                var context = new ClientContext(Configuration.ServiceSiteUrl);
                context.Credentials = onlineCredentials;
                return context;

            static void Main(string[] args)  
                var clientContext=GetonlineContext();  
                List list = clientContext.Web.Lists.GetByTitle("<library>"); 
                var fileName = "test.docx";
                CamlQuery camlQuery = new CamlQuery();
                camlQuery.ViewXml =
                           <Where><Eq><FieldRef Name='FileLeafRef' /><Value Type='File'>" + fileName + @"</Value></Eq></Where> 
                           <ViewFields><FieldRef Name='FileRef' /><FieldRef Name='FileLeafRef' /></ViewFields> 
                ListItemCollection listItems = list.GetItems(camlQuery);
                foreach (ListItem oListItem in listItems)
                    //do something

    Friday, October 2, 2020 1:13 PM
  • Thank you for the response. I already have that line. Please see code below. Also, this code is running on SharePoint 2016 On Prem:

    function getByID()

    var ctx = new SP.ClientContext.get_current();
    var customList = ctx.get_web().get_lists().getByTitle('Announcements');
    var listItem = customList.getItemById(itemId);
    anncTitle = listItem.get_item("Title");
    anncDate = listItem.get_item("Created");

         //Need to run this here as variables are not being preserved.
         if (anncTitle != "") 
         SP.SOD.executeFunc('sp.js', 'SP.ClientContext', addListItem);
    function(sender, args){ alert('Error: ' + args.get_message()); }



    Friday, October 2, 2020 1:30 PM
  • SharePoint forums have migrated to QnA




    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    • Proposed as answer by Guido Franzke Monday, October 5, 2020 5:58 AM
    • Marked as answer by Guido Franzke Friday, October 9, 2020 6:19 AM
    Friday, October 2, 2020 2:13 PM