Microsoft KB Archive/310285

= How to retrieve the security descriptor of a message by using WebDav in Visual C# =

Article ID: 310285

Article Last Modified on 12/11/2006

-

APPLIES TO


 * Microsoft Visual C# 2005
 * Microsoft Visual C# .NET 2003 Standard Edition
 * Microsoft Visual C# .NET 2002 Standard Edition
 * Microsoft Exchange 2000 Server Standard Edition
 * Microsoft XML Core Services 4.0
 * Microsoft XML Core Services 4.0

-



This article was previously published under Q310285



INTRODUCTION
This article describes how to use Microsoft XML version 3.0 or Microsoft XML version 4.0 to retrieve the security descriptor of a message in Microsoft Visual C#.



MORE INFORMATION
To retrieve the security descriptor of a message, follow these steps:  Start Microsoft Visual Studio .NET or Microsoft Visual Studio 2005. On the File menu, click New, and then click Project. In the Visual C# Project Types list, select Console Application.

Note In Visual Studio 2005, click Visual C#.

In Visual Studio .NET, Class1.cs is created by default. In Visual Studio 2005, Program.cs is created by default. Add a reference to XML version 3.0 or to XML version 4.0. To do this, follow these steps:  On the Project menu, click Add Reference. On the COM tab, click either Microsoft XML v3.0 or Microsoft XML v4.0, and then click Select.

Note In Visual Studio 2005, you do not have to click Select. In the Add References dialog box, click OK to accept your selection.</li> If you receive a message to generate wrappers for the libraries that you selected, click Yes.</li></ol> </li>  In the code window, replace all the code with the following sample code: using System; using System.Reflection;

namespace WebDav {  class Class1 {        public static void Main(string [] args) {        try {                 MSXML2.XMLHTTP30 oXMLHttp = new MSXML2.XMLHTTP30; // TODO: Replace with the URL of your object. string sUrl = &quot;http://ExchServer/public/MyApplication/Test.eml&quot;; string strSDType = &quot;descriptor&quot;; string sQuery; sQuery = &quot;<?xml version='1.0' encoding='utf-8'?>&quot; + &quot;<propfind xmlns=\&quot;DAV:\&quot;>&quot; + &quot;<prop xmlns:r=\&quot;http://schemas.microsoft.com/exchange/security/\&quot;>&quot; + &quot; &quot; + &quot;  <r:&quot; + strSDType + &quot;/>&quot; + &quot; &quot; + &quot; &quot;;

//TODO: Insert correct credentials. oXMLHttp.open(&quot;PROPFIND&quot;, sUrl, false, @&quot;UserDomain\UserAlias&quot;, &quot;UserPassword&quot;);

oXMLHttp.setRequestHeader(&quot;Content-Type&quot;, &quot;text/xml&quot;); oXMLHttp.setRequestHeader(&quot;Translate&quot;, &quot;f&quot;); oXMLHttp.setRequestHeader(&quot;Depth&quot;, &quot;0&quot;); oXMLHttp.setRequestHeader(&quot;Content-Length&quot;, &quot;&quot; + sQuery.Length); oXMLHttp.send(sQuery);

Console.WriteLine(oXMLHttp.status); Console.WriteLine(oXMLHttp.statusText); Console.WriteLine(oXMLHttp.responseText); }        catch (Exception e)         { Console.WriteLine(&quot;{0} Exception caught.&quot;, e); }     }   } } </li> Modify the previous sample code where you see the TODO lines.</li> Press F5 to build and to run the program.</li> Verify your response to make sure that you receive the security descriptor of the message.</li></ol>

Additional query words: Microsoft XML retrieve security descriptor message

Keywords: kbhowto kbmsg kbcode KB310285

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.