0

I have a ASP.NET Web Service and inside it I'm using SharePoint 2010 Client Object Model. The promblem is that I'm using a CAML Query to retrive some items for a user that is given. When I choose, so that my app uses the Visual Studio Development Server, all works properly, but when I switch to Local IIS Web server, the CAML returns 0 items what so ever.

        ClientContext clientContext = new ClientContext("http://mySiteCol");

        Web web = clientContext.Web;

        var query = from list in web.Lists
                    where list.Title == "listName"
                    select list;

        var result = clientContext.LoadQuery(query);
        clientContext.ExecuteQuery();

        List lista = result.ToList().FirstOrDefault();

        CamlQuery camlQuery = new CamlQuery();
        camlQuery.ViewXml = string.Format("<View><Query><Where>" +
                             "<Eq><FieldRef Name='staticColumnName' />" + 
                             "<Value Type='User'>{0}</Value></Eq>" + 
                             "</Where></Query></View>", userName);

        ListItemCollection listItemCollection = lista.GetItems(camlQuery);

        clientContext.Load(listItemCollection);
        clientContext.ExecuteQuery();

CAML dind't work with user ID either.

Thanks.

  • It's been a few years since I did SharePoint, but I remember certain stuff had to run locally on the SharePoint installation (the physical server) to work. When you run it using the Visual Studio Development Server, does it connect to a local SharePoint instance? – Garrison Neely Sep 17 '13 at 15:51
  • Yes. That is the only way it works. Using IIS Web Server is the problem. It gets the list but the CAML returns no results. – cotoarba bogdan Sep 18 '13 at 06:11
  • Got the issue. My app pool was running with a default app pool user wich had no permissions on SharePoint. So I made iti to run with my user and everithing was solved. – cotoarba bogdan Sep 18 '13 at 07:37
  • I suggest putting this as an answer for future searchers. – Garrison Neely Sep 18 '13 at 14:40

2 Answers2

1

Have you looked into permissions? Probably the calls from your Webservice to SharePoint when running in IIS are done as the AppPool account

pateketu
  • 451
  • 2
  • 8
0

Have you tried deleting the

<View><Query></Query></View>

?

I mean like this:

string.Format("<Where>" +
              "<Eq><FieldRef Name='staticColumnName' />" + 
              "<Value Type='User'>{0}</Value></Eq>" + 
              "</Where>", userName);

Hope this helps.

kml
  • 163
  • 6