WebDAV - Permissions on message with attachments





What permissions do you need to set on an exchange message item to be
able to use the
X-MS-ENUMATTS WebDAV method.

I am using code supplied directly from MSDN web site and I always get a
403 Error returned in the response object. I have assumed that this
should be to do with not having access to the attachment of the
message. I can run all other queries ok. If I query the
attachment-filename property I get a similar error in the HttpResponse.
I am wondering what it is that is stopping me obtaining attachments
from Outlook Web Access.

If you have any pointers - or if any of you have seen this situation
before then I would be very grateful. The code I am using is below.. as
I say, I always get a 403 from the response object and I am unable to
find out why.

Can anybody can tell me what permissions I need to set on the message
and how I set them with WebDAV - possibly a sample?



[STAThread]
static void Main(string[] args)
{
// Variables.
System.Net.HttpWebRequest Request;
System.Net.WebResponse Response;
System.Net.CredentialCache MyCredentialCache;
string strMessageURI =
"http://server/exchange/username/inbox/TestMessage.eml/";;
string strUserName = "username";
string strPassword = "!Password";
string strDomain = "Domain";
System.IO.Stream ResponseStream = null;
System.Xml.XmlDocument ResponseXmlDoc = null;
System.Xml.XmlNode root = null;
System.Xml.XmlNamespaceManager nsmgr = null;
System.Xml.XmlNodeList PropstatNodes = null;
System.Xml.XmlNodeList HrefNodes = null;
System.Xml.XmlNode StatusNode = null;
System.Xml.XmlNode PropNode = null;

try
{
// Create a new CredentialCache object and fill it with the
network
// credentials required to access the server.
MyCredentialCache = new System.Net.CredentialCache();
MyCredentialCache.Add( new System.Uri(strMessageURI),
"NTLM",
new System.Net.NetworkCredential(strUserName,
strPassword, strDomain)
);

// Create the HttpWebRequest object.
Request =
(System.Net.HttpWebRequest)HttpWebRequest.Create(strMessageURI);

// Add the network credentials to the request.
Request.Credentials = MyCredentialCache;

// Specify the method.
Request.Method = "X-MS-ENUMATTS";

// Send the X-MS-ENUMATTS method request and get the
// response from the server.
Response = (HttpWebResponse)Request.GetResponse();

// Get the XML response stream.
ResponseStream = Response.GetResponseStream();

// Create the XmlDocument object from the XML response
stream.
ResponseXmlDoc = new System.Xml.XmlDocument();

// Load the XML response stream.
ResponseXmlDoc.Load(ResponseStream);

// Get the root node.
root = ResponseXmlDoc.DocumentElement;

// Create a new XmlNamespaceManager.
nsmgr = new
System.Xml.XmlNamespaceManager(ResponseXmlDoc.NameTable);

// Add the DAV: namespace, which is typically assigned the
a: prefix
// in the XML response body. The namespaceses and their
associated
// prefixes are listed in the attributes of the
DAV:multistatus node
// of the XML response.
nsmgr.AddNamespace("a", "DAV:");

// Add the http://schemas.microsoft.com/mapi/proptag/
namespace, which
// is typically assigned the d: prefix in the XML response
body.
nsmgr.AddNamespace("d",
"http://schemas.microsoft.com/mapi/proptag/";);

// Use an XPath query to build a list of the DAV:propstat
XML nodes,
// corresponding to the returned status and properties of
// the file attachment(s).
PropstatNodes = root.SelectNodes("//a:propstat", nsmgr);

// Use an XPath query to build a list of the DAV:href
nodes,
// corresponding to the URIs of the attachement(s) on the
message.
// For each DAV:href node in the XML response, there is an
// associated DAV:propstat node.
HrefNodes = root.SelectNodes("//a:href", nsmgr);

// Attachments found?
if(HrefNodes.Count > 0)
{
// Display the number of attachments on the message.
Console.WriteLine(HrefNodes.Count + " attachments
found...");

// Iterate through the attachment properties.
for(int i=0;i<HrefNodes.Count;i++)
{
// Use an XPath query to get the DAV:status node from
the DAV:propstat node.
StatusNode =
PropstatNodes[i].SelectSingleNode("a:status", nsmgr);

// Check the status of the attachment properties.
if(StatusNode.InnerText != "HTTP/1.1 200 OK")
{
Console.WriteLine("Attachment: " +
HrefNodes[i].InnerText);
Console.WriteLine("Status: " +
StatusNode.InnerText);
Console.WriteLine("");
}
else
{
Console.WriteLine("Attachment: " +
HrefNodes[i].InnerText);
Console.WriteLine("Status: " +
StatusNode.InnerText);

// Get the CdoPR_ATTACH_FILENAME_W MAPI property
tag,
// corresponding to the attachment file name. The
// http://schemas.microsoft.com/mapi/proptag/
namespace is typically
// assigned the d: prefix in the XML response
body.
PropNode =
PropstatNodes[i].SelectSingleNode("a:prop/d:x3704001f", nsmgr);
Console.WriteLine("Attachment name: " +
PropNode.InnerText);

// Get the CdoPR_ATTACH_EXTENSION_W MAPI property
tag,
// corresponding to the attachment file extension.
PropNode =
PropstatNodes[i].SelectSingleNode("a:prop/d:x3703001f", nsmgr);
Console.WriteLine("File extension: " +
PropNode.InnerText);

// Get the CdoPR_ATTACH_SIZE MAPI property tag,
// corresponding to the attachment file size.
PropNode =
PropstatNodes[i].SelectSingleNode("a:prop/d:x0e200003", nsmgr);
Console.WriteLine("Attachment size: " +
PropNode.InnerText);

Console.WriteLine("");
}
}
}
else
{
Console.WriteLine("No attachments found.");
}

// Clean up.
ResponseStream.Close();
Response.Close();

}
catch(Exception ex)
{
// Catch any exceptions. Any error codes from the
X-MS-ENUMATTS
// method request on the server will be caught here, also.
Console.WriteLine(ex.Message);
}


Best Regards,

James Scanlon

.



Relevant Pages

  • Re: Thinking outside the box on file systems
    ... If the /etc/shadow permissions depend on inherited ACLs to enforce access then that one little command just made your shadow file world-readable/writeable. ... I can probably have an open directory handle to a volume in a completely different namespace, a volume which isn't even *MOUNTED* in my current fs namespace. ... Yes, the effective acl of the open directory is kept in memory, but in the directory itself, not the handle to it, thus when the directory is moved, it's acl is recomputed for the new location and updated immediately. ...
    (Linux-Kernel)
  • Re: scanning sysfs to populate /dev
    ... the kernel only deals with devices by their device code. ... > Having a device namespace in the kernel, is a departure from that philosophy. ... > external policy, and now it is migrating to device drivers. ... permissions for any nodes it just creates them with the default permissions ...
    (comp.os.linux.development.system)
  • Re: User rigths for WMI access
    ... >> a namespace additional permissions may be required, ... > Our application performs querys to operating system classes (such as ... > We know a "local administrator" user can perform these queries, ...
    (microsoft.public.windowsxp.wmi)
  • Re: User rights analysis
    ... >which and which kinds of resources exist in this forest. ... This "personal" namespace contains all the ... resources the user has permissions to and can be mapped as a drive. ... The personal namespace ...
    (microsoft.public.windows.server.active_directory)
  • Re: Thinking outside the box on file systems
    ... People, groups, managers, and other objects with have permissions. ... One might tag a file with the object that created it so you could implement "self" rights which might be use to replace the concept of /tmp directories. ... As long as there is not a reasonably-close-to-1-to-1 mapping between UNIX semantics and your "outside the box" semantics, the latter can't really be used. ...
    (Linux-Kernel)