469,573 Members | 1,795 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,573 developers. It's quick & easy.

Access Denied from WebDAV


I'm trying to write a windows service which reads some emails from Exchange
Server through WebDAV, using C#.NET 2.0. Everything works fine when testing,
using a little Forms application to test all the backend classes. However,
when I try to run the actual service it gets an access denied message when
trying to get the emails.

We have other services written in VB.NET 1.1 which use the exact same
technique, and run on the same server... and they work fine. So why would it
stop working when run as a .NET 2.0 service?

Here is the function which actually gets the email:

protected XmlDataDocument GetOldestEmail(string mailbox)
{
MSXML2.ServerXMLHTTP40 server = new MSXML2.ServerXMLHTTP40();
server.open("SEARCH", mailbox, false, mUsername, mPassword);
server.setRequestHeader("Depth", "1");
server.setRequestHeader("Content-type", "text/xml");
server.setRequestHeader("Range", "Rows=0-0");

string select = "<?xml version=\"1.0\"?>"
+ "<D:searchrequest xmlns:D = \"DAV:\">"
+ "<D:sql>"
+ "SELECT \"DAV:href\", "
+ "\"urn:schemas:httpmail:subject\", "
+ "\"urn:schemas:httpmail:textdescription\", "
+
"\"urn:schemas:httpmail:htmldescription\", "
+ "\"urn:schemas:httpmail:datereceived\", "
+ "\"urn:schemas:httpmail:from\" "
+ "FROM scope('shallow traversal of \"" + mailbox + "\"')"
+ "WHERE \"DAV:ishidden\"=false "
+ "AND \"DAV:isfolder\"=false "
+ "ORDER BY \"urn:schemas:httpmail:datereceived\""
+ "</D:sql></D:searchrequest>";
server.send(select);

XmlDataDocument dataDoc = new XmlDataDocument();
dataDoc.LoadXml(server.responseText);

return dataDoc;
}

The mailbox would be something like
https://owa.companyname.com/exchange/dispatch/IMOnsite and the
username/password are definately correct.

Any thoughts on why I'm getting Access Denied?
Oct 11 '06 #1
0 1275

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Rade Josovic | last post: by
reply views Thread by Michael G. Schneider | last post: by
3 posts views Thread by Glenn Holliday | last post: by
2 posts views Thread by Raj Dhrolia | last post: by
reply views Thread by SimpleSimple | last post: by
7 posts views Thread by Steve Drake | last post: by
reply views Thread by Gary Chamberlain via .NET 247 | last post: by
reply views Thread by arjen1984 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.