DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 8 of 8

Thread: WebDAV Access Denied Error

  1. #1
    Join Date
    Oct 2006
    Posts
    12

    WebDAV Access Denied Error

    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:

    Code:
    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?

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Under what user account is the service configured to run?
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Oct 2006
    Posts
    12
    LocalSystem. I've also tried using my admin account with no success.

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    I don't think LocalSystem has access to the network.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  5. #5
    Join Date
    Oct 2006
    Posts
    12
    I just tried Network Service and Local Service, and got Access Denied when trying to start the service. What account should I use?

  6. #6
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    How about the account that works for the "other services" you mentioned in your initial post?
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  7. #7
    Join Date
    Oct 2006
    Posts
    12
    They are under LocalSystem.

  8. #8
    Join Date
    Oct 2006
    Posts
    12
    Ok, so I tried logging in using my admin account again and it's working. I tried it before and it didn't work, though to be fair it gave a different error message. I didn't change anything though. So basically it's working, but I'm still confused...

    And yes, the other services are still running under Local System.

Similar Threads

  1. Replies: 5
    Last Post: 09-03-2013, 03:59 AM
  2. Sql server Access denied ERROR
    By persian_celina in forum Database
    Replies: 3
    Last Post: 06-14-2005, 06:05 AM
  3. Access denied to 'D:\wwwroot\web'
    By .need help in forum ASP.NET
    Replies: 2
    Last Post: 03-10-2003, 06:04 PM
  4. Writing in HKEY_LOCAL_MACHINE...Access is denied
    By Martin in forum VB Classic
    Replies: 22
    Last Post: 12-03-2001, 04:53 AM
  5. Access denied error HELP!!!
    By Ryan in forum VB Classic
    Replies: 5
    Last Post: 04-25-2000, 03:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center