Monday, August 27, 2012

Silverlight: Preventing authentication window / login prompt while connecting SharePoint with different credentials using DataContext (REST)

Silverlight: Preventing authentication window / login prompt while connecting SharePoint with different credentials using DataContext (REST)

I'm programming a Silverlight client to consume a list in Sharepoint 2010 using REST. It's supposed to work as a gadget on users Windows desktop.

My requirement is, logging into Sharepoint with specific credentials instead of current logged user. It works fine with the source code I pasted down and I'm able to fetch the list content as expected, however, everytime I run the software, Windows shows a login box - authentication window to user before estabilishing a connection to Sharepoint.

If user skips it by clicking "cancel" the rest of software works normally.

So I need to prevent this login box.

ObservableCollection<ShoutBoxItem> allItems = new ObservableCollection<ShoutBoxItem>();   ShoutsProxy.TwitterDataContext context = new TwitterDataContext(new Uri(webServiceUrl));  context.HttpStack = HttpStack.ClientHttp; context.Credentials = new System.Net.NetworkCredential(username, password, domain); context.UseDefaultCredentials = false;  DataServiceQuery<ShoutBoxItem> query = DataServiceQuery<ShoutBoxItem>)context.ShoutBox; query.BeginExecute(onGetShoutBoxItemsComplete, query); 

So at exactly "query.beginexecute" line, a login box comes up immediately.

Any suggestions?

Greetings from Duisburg, Alper Barkmaz

Answers & Comments...




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog