<feed xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US">
    <title>Sharvan Dhaka</title>
    <link rel="self" type="application/xml" href="http://geekswithblogs.net/Dhaka/Atom.aspx" />
    <subtitle type="html">blog</subtitle>
    <id>http://geekswithblogs.net/Dhaka/Default.aspx</id>
    <author>
        <name>Sharvan Dhaka</name>
        <uri>http://geekswithblogs.net/Dhaka/Default.aspx</uri>
    </author>
    <generator uri="http://subtextproject.com" version="Subtext Version 0.0.0.0">Subtext</generator>
    <updated>2006-10-18T23:39:00Z</updated>
    <entry>
        <title>How to convert a string to a byte array and convert a byte array to a string c# asp.net</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Dhaka/archive/2006/10/15/94123.aspx" />
        <id>http://geekswithblogs.net/Dhaka/archive/2006/10/15/94123.aspx</id>
        <published>2006-10-15T17:42:00-05:00:00</published>
        <updated>2006-10-18T23:39:00Z</updated>
        <content type="html">&lt;DIV&gt;&lt;FONT color=#ff0000&gt;Convert a string to a byte array&lt;/FONT&gt; &lt;BR&gt;&lt;BR&gt;string myString = "a test string"; &lt;BR&gt;byte[] myByteArray = new byte[myString.Length]; &lt;BR&gt;int i = 0; &lt;BR&gt;foreach(char c in InStr.ToCharArray()) &lt;BR&gt;{ &lt;BR&gt;myByteArray [i] = (byte)c; &lt;BR&gt;i++; &lt;BR&gt;} &lt;BR&gt;&lt;BR&gt;&lt;FONT color=#ff0000&gt;Convert a byte array to a string&lt;/FONT&gt; &lt;BR&gt;&lt;BR&gt;System.Text.Encoding enc = System.Text.Encoding.ASCII; &lt;BR&gt;byte[] myByteArray = enc.GetBytes("a text string); &lt;BR&gt;string myString = enc.GetString(myByteArray );&lt;/DIV&gt;&lt;img src="http://geekswithblogs.net/Dhaka/aggbug/94123.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Dhaka/comments/94123.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Dhaka/comments/commentRss/94123.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Dhaka/services/trackbacks/94123.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Serialize &amp; Deserialize c# asp.net</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Dhaka/archive/2006/10/15/94124.aspx" />
        <id>http://geekswithblogs.net/Dhaka/archive/2006/10/15/94124.aspx</id>
        <published>2006-10-15T17:43:00-05:00:00</published>
        <updated>2006-10-18T23:38:00Z</updated>
        <content type="html">&lt;DIV&gt;Serialize (convert an object instance to an XML document): &lt;BR&gt;&lt;BR&gt;&lt;FONT color=#009900&gt;// Assuming obj is an instance of an object&lt;/FONT&gt; &lt;BR&gt;XmlSerializer ser = new XmlSerializer(obj.GetType()); &lt;BR&gt;System.Text.StringBuilder sb = new System.Text.StringBuilder(); &lt;BR&gt;System.IO.StringWriter writer = new System.IO.StringWriter(sb); &lt;BR&gt;ser.Serialize(writer, obj); &lt;BR&gt;XmlDocument doc = new XmlDocument(); &lt;BR&gt;doc.LoadXml(sb.ToString()); &lt;BR&gt;&lt;BR&gt;Deserialize (convert an XML document into an object instance): &lt;BR&gt;&lt;BR&gt;&lt;FONT color=#33cc00&gt;//Assuming doc is an XML document containing a serialized object and objType is a&lt;/FONT&gt; System.Type set to the type of the object. &lt;BR&gt;XmlNodeReader reader = new XmlNodeReader(doc.DocumentElement); &lt;BR&gt;XmlSerializer ser = new XmlSerializer(objType); &lt;BR&gt;object obj = ser.Deserialize(reader); &lt;BR&gt;&lt;FONT color=#33cc00&gt;// Then you just need to cast obj into whatever type it is eg: &lt;BR&gt;&lt;/FONT&gt;MyClass myObj = (MyClass)obj;&lt;/DIV&gt;&lt;img src="http://geekswithblogs.net/Dhaka/aggbug/94124.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Dhaka/comments/94124.aspx</wfw:comment>
        <slash:comments>2</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Dhaka/comments/commentRss/94124.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Dhaka/services/trackbacks/94124.aspx</trackback:ping>
    </entry>
    <entry>
        <title>How to get the HTML name attribute of ASP.Net Control c# as.net</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Dhaka/archive/2006/10/15/94125.aspx" />
        <id>http://geekswithblogs.net/Dhaka/archive/2006/10/15/94125.aspx</id>
        <published>2006-10-15T17:49:00-05:00:00</published>
        <updated>2006-10-18T23:36:00Z</updated>
        <content type="html">&lt;DIV&gt;&lt;FONT color=#009900&gt;//Function to get the HTML name of the server control from the Client Id &lt;BR&gt;&lt;BR&gt;// Parameters: &lt;BR&gt;&lt;BR&gt;// clientId - Control.ClientId &lt;BR&gt;&lt;BR&gt;// serverId - Control.id&lt;/FONT&gt; &lt;BR&gt;&lt;BR&gt;private string GetHTMLNameById(string clientId, string serverId) &lt;BR&gt;&lt;BR&gt;{ &lt;BR&gt;&lt;BR&gt;int pos = serverId.IndexOf('_'); &lt;BR&gt;&lt;BR&gt;string HTMLName = ""; &lt;BR&gt;&lt;BR&gt;if(pos &gt;= 0) &lt;BR&gt;&lt;BR&gt;{ &lt;BR&gt;&lt;BR&gt;pos = clientId.IndexOf(serverId); &lt;BR&gt;&lt;BR&gt;HTMLName = clientId.Remove(pos, serverId.Length); &lt;BR&gt;&lt;BR&gt;HTMLName = HTMLName.Replace('_', '$'); &lt;BR&gt;&lt;BR&gt;HTMLName += serverId; &lt;BR&gt;&lt;BR&gt;} &lt;BR&gt;&lt;BR&gt;else &lt;BR&gt;&lt;BR&gt;HTMLName = clientId.Replace('_', '$'); &lt;BR&gt;&lt;BR&gt;return HTMLName; &lt;BR&gt;&lt;BR&gt;}&lt;/DIV&gt;&lt;img src="http://geekswithblogs.net/Dhaka/aggbug/94125.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Dhaka/comments/94125.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Dhaka/comments/commentRss/94125.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Dhaka/services/trackbacks/94125.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Force a page to download a file c# asp.net</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Dhaka/archive/2006/10/15/94132.aspx" />
        <id>http://geekswithblogs.net/Dhaka/archive/2006/10/15/94132.aspx</id>
        <published>2006-10-15T17:56:00-05:00:00</published>
        <updated>2006-10-18T23:34:00Z</updated>
        <content type="html">&lt;img src="http://geekswithblogs.net/Dhaka/aggbug/94132.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Dhaka/comments/94132.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Dhaka/comments/commentRss/94132.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Dhaka/services/trackbacks/94132.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Read Response of a web request in a byte Array with C# Asp.net</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Dhaka/archive/2006/10/15/94133.aspx" />
        <id>http://geekswithblogs.net/Dhaka/archive/2006/10/15/94133.aspx</id>
        <published>2006-10-15T17:57:00-05:00:00</published>
        <updated>2006-10-18T23:29:00Z</updated>
        <content type="html">&lt;DIV&gt;this code snippet read the respone fo a web request through binary reader&lt;/DIV&gt;
&lt;DIV&gt; &lt;/DIV&gt;
&lt;DIV&gt;private byte[] getByte(string URL) &lt;BR&gt;{ &lt;BR&gt;HttpWebRequest wrGETURL = (HttpWebRequest)WebRequest.Create(URL); &lt;BR&gt;System.Net.HttpWebResponse webresponse = (HttpWebResponse)wrGETURL.GetResponse(); &lt;BR&gt;string ct = webresponse.ContentType; &lt;BR&gt;Stream objStream = webresponse.GetResponseStream(); &lt;BR&gt;BinaryReader breader = new BinaryReader(objStream); &lt;BR&gt;byte[] buffer = breader .ReadBytes((int)webresponse.ContentLength); &lt;BR&gt;return buffer; &lt;BR&gt;}&lt;/DIV&gt;&lt;img src="http://geekswithblogs.net/Dhaka/aggbug/94133.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Dhaka/comments/94133.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Dhaka/comments/commentRss/94133.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Dhaka/services/trackbacks/94133.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Perform a Case-IN sensitive Search in .NET Using XPath</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Dhaka/archive/2006/10/15/94139.aspx" />
        <id>http://geekswithblogs.net/Dhaka/archive/2006/10/15/94139.aspx</id>
        <published>2006-10-15T18:37:00-05:00:00</published>
        <updated>2006-10-15T19:01:00Z</updated>
        <content type="html">&lt;P&gt;The following code shows to how to perform a case-sensitive search in .NET using XPath. &lt;/P&gt;
&lt;P&gt;and contains is used as like operator in xpath.&lt;/P&gt;
&lt;P&gt;XML File: &lt;CODE&gt;&lt;BR&gt;&lt;FONT color=#ff0000&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;BR&gt;&amp;lt;USERS&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;USER&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;NAME&amp;gt;sharvan&amp;lt;/NAME&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;PASSWORD&amp;gt;dhaka&amp;lt;/PASSWORD&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/USER&amp;gt;&lt;BR&gt;&amp;lt;/USERS&amp;gt;&lt;BR&gt;&lt;BR&gt;Code File:&lt;BR&gt;&lt;/FONT&gt;&lt;/CODE&gt;&lt;CODE&gt;&lt;BR&gt;&lt;FONT color=#ff0000&gt;&amp;lt;%@ Import Namespace="System.Data" %&amp;gt;&lt;BR&gt;&amp;lt;%@ Import Namespace="System.Xml" %&amp;gt;&lt;BR&gt;&amp;lt;%@ Page Language="C#" Debug="true" %&amp;gt;&lt;BR&gt;&lt;BR&gt;&amp;lt;SCRIPT runat="server"&amp;gt;&lt;BR&gt;void Page_Load(object sender, System.EventArgs e)&lt;BR&gt;&lt;/FONT&gt;&lt;/CODE&gt;&lt;CODE&gt;&lt;FONT color=#ff0000&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(!Page.IsPostBack)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XmlDocument xmlDoc = new XmlDocument();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlDoc.Load(Server.MapPath("user.xml"));&amp;nbsp;&lt;BR&gt;&amp;nbsp;XmlNodeList nodeList = xmlDoc.SelectNodes("Users/User[contains(translate(Name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),translate('Sharvan', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'))]");&lt;BR&gt;&amp;nbsp;Response.Write(nodeList.Count.ToString());&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/FONT&gt;&lt;BR&gt;&lt;/CODE&gt;&lt;CODE&gt;&lt;BR&gt;1. Case of matching the beginning of some text.&lt;BR&gt;miCommunities% LIKE where wildcard is at end&lt;BR&gt;&lt;/CODE&gt;&lt;CODE&gt;&lt;BR&gt;&amp;nbsp;Corresponding XPath expression predicate,&lt;BR&gt;[ starts-with( Name , 'miCommunities')]&lt;BR&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;2. Case of matching within some text.&lt;BR&gt;%miCommunities% LIKE where there is a wildcard at both ends&lt;BR&gt;&lt;BR&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt; Corresponding XPath expression predicate,&lt;BR&gt;[ contains( Name , 'miCommunities')]&lt;/CODE&gt;&lt;/PRE&gt;&lt;img src="http://geekswithblogs.net/Dhaka/aggbug/94139.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Dhaka/comments/94139.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Dhaka/comments/commentRss/94139.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Dhaka/services/trackbacks/94139.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Search in Xml File through XPATH</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Dhaka/archive/2006/10/15/94138.aspx" />
        <id>http://geekswithblogs.net/Dhaka/archive/2006/10/15/94138.aspx</id>
        <published>2006-10-15T18:29:00-05:00:00</published>
        <updated>2006-10-15T18:29:00Z</updated>
        <content type="html">&lt;P&gt;Using xpath you can find elements in a xml file.&lt;BR&gt;There is more to XML then just a way of describing data. Over the years, a number of XML-based standards have emerged. Among the most fundamental ones are XSD (XML Schema Definition), XPath Query, XSLT (Extensible Stylesheet Language Transformation), SOAP (Simple Object Access Protocol), and WSDL (Web Services Description Language). All build on top of the XML syntax.&lt;BR&gt;&lt;BR&gt;&lt;STRONG&gt;The Sample XML Document for the Series of Articles&lt;BR&gt;&lt;BR&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;This series of articles assumes that you are familiar with XML itself. The sample XML document used throughout the articles is a list of employees, which must have for each employee the first name, last name, phone number, and e-mail address, and also can provide the job title and a Web address.&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;Employees&amp;gt;
   &amp;lt;Employee ID="1"&amp;gt;
      &amp;lt;FirstName&amp;gt;Klaus&amp;lt;/FirstName&amp;gt;
      &amp;lt;LastName&amp;gt;Salchner&amp;lt;/LastName&amp;gt;
      &amp;lt;PhoneNumber&amp;gt;410-727-5112&amp;lt;/PhoneNumber&amp;gt;
      &amp;lt;EmailAddress&amp;gt;klaus_salchner@hotmail.com&amp;lt;/EmailAddress&amp;gt;
      &amp;lt;WebAddress&amp;gt;http:&lt;SPAN class=codeComment&gt;//www.enterprise-minds.com&amp;lt;/WebAddress&amp;gt;&lt;/SPAN&gt;
      &amp;lt;JobTitle&amp;gt;Sr. Enterprise Architect&amp;lt;/JobTitle&amp;gt;
   &amp;lt;/Employee&amp;gt;
   &amp;lt;Employee ID="2"&amp;gt;
      &amp;lt;FirstName&amp;gt;Peter&amp;lt;/FirstName&amp;gt;
      &amp;lt;LastName&amp;gt;Pan&amp;lt;/LastName&amp;gt;
      &amp;lt;PhoneNumber&amp;gt;604-111-1111&amp;lt;/PhoneNumber&amp;gt;
      &amp;lt;EmailAddress&amp;gt;peter.pan@fiction.com&amp;lt;/EmailAddress&amp;gt;
      &amp;lt;JobTitle&amp;gt;Sr. Developer&amp;lt;/JobTitle&amp;gt;
   &amp;lt;/Employee&amp;gt;
&amp;lt;/Employees&amp;gt;
&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;A quick note to editing XML documents in Visual Studio .NET 2003: When you open up a XML document, you see at the bottom of the window an "XML" and "Data" tab. The XML tab allows you to edit the XML. It also formats the XML nicely for you with indentions and all that. The Data tab parses the XML and shows a data grid. You can add new nodes by adding new rows to the data grid and entering corresponding values. Using the example data, this would be new Employees.&lt;/P&gt;
&lt;P&gt;You also can show a document outline through the "View | Other Windows | Document Outline" menu, which shows you a hierarchy of all the nodes in the XML document. Selecting a node in the "document outline" will automatically select it in the XML document too.&lt;BR&gt;&lt;BR&gt;&lt;/P&gt;
&lt;H3&gt;The Fundamentals of XPath Queries&lt;/H3&gt;
&lt;P&gt;Once you have data in XML format, you will want to be able to navigate and search its nodes. You don't want to have to parse the whole XML document to find that there are two Employee nodes. That would be terribly inefficient. You want to apply an XPath query, which then gives you all the matching nodes. To find all Employee nodes, you would run the following XPath query:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=codeComment&gt;//Employee&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;If you use the table above, this query will return two nodes, each representing an employee. This makes it very easy to find matching nodes and walk through the result set.&lt;/P&gt;
&lt;P&gt;XPath is a standard (XPath 1.0) and can be found at &lt;A href="http://www.w3.org/TR/xpath/" target=new&gt;&lt;FONT color=#002c99&gt;http://www.w3.org/TR/xpath/&lt;/FONT&gt;&lt;/A&gt;. The working draft of XPath 2.0 can be found at &lt;A href="http://www.w3.org/TR/2001/WD-xpath20-20011220/" target=new&gt;&lt;FONT color=#002c99&gt;http://www.w3.org/TR/2001/WD-xpath20-20011220/&lt;/FONT&gt;&lt;/A&gt;. Let's look more closely at some of the most common XPath operators.&lt;/P&gt;
&lt;P&gt;
&lt;TABLE cellSpacing=0 cellPadding=3 border=1&gt;
&lt;TBODY&gt;
&lt;TR vAlign=top&gt;
&lt;TD&gt;&lt;B&gt;Operator&lt;/B&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;B&gt;Description&lt;/B&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;/ (child operator)&lt;/TD&gt;
&lt;TD&gt;Refers to the root of the XML document when used at the beginning of the XPath expression. The child operator is used to specify the next child to select. The expression "/Employees/Employee", for, example says, start at the root of the XML document, select the Employees node and then select all the Employee child nodes within the Employees node. This will return the two Employee nodes in the sample XML document.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;// (recursive descendant operator)&lt;/TD&gt;
&lt;TD&gt;The recursive descendant operator indicates to include all descendant nodes in the search. Using the operator at the beginning of the XPath expression means you start from the root of the XML document. The expression "//LastName" starts at the root and finds any LastName node. The expression "/Employees//LastName" selects the Employees node and then, within that node, finds any LastName node. It yields the same result, but searches in a different way.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;* (wildcard operator)&lt;/TD&gt;
&lt;TD&gt;The wildcard operator finds any node. The expression "/*" finds any node under the root, which in our case is Employees. The expression "/Employees/*" means find any node under the Employees node, which in our case results with the two Employee nodes. Now what is the difference between the "/Employees" and "/Employees/*" expression? The first expression returns the Employees node but the second node finds any node under the Employees node, meaning it returns the two Employee nodes. The expression "//*" means to select any node including descendant nodes, so it will effectively list every single node in the complete XML document.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;. (current context operator)&lt;/TD&gt;
&lt;TD&gt;The current context operator refers to the current context. For example, you have written some code that selected the Employees node and then from there you run the expression "./Employee", which means it starts out from the currently selected Employees node and then selects the two Employee nodes. The expression "Employee" would yield the same result because it also starts out from the current context. Similar the expression ".//LastName" means start from the current context, the Employees node, and find any LastName node including any descendant nodes.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;.. (parent operator)&lt;/TD&gt;
&lt;TD&gt;The parent operator refers to the parent. For example, the expression "/Employees/Employee/.." returns the Employees node because you navigate down to the Employee nodes and then tell it to return its parent, which is the Employees node.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;@ (attribute operator)&lt;/TD&gt;
&lt;TD&gt;The attribute operator refers to an attribute instead of an element. The expression "/Employees//@ID" selects any ID attribute it finds under the Employees node. Now, keep in mind that the XPath query always returns the selected node. In the case of an attribute, the node below it is its value. So, the expression really two returns nodes, each with the value of each selected attribute. Furthermore, you can use the wildcard operator with attributes, so "/Employees//@*" means any attribute underneath the Employees node.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;[ ] (filter operator)&lt;/TD&gt;
&lt;TD&gt;You can apply a filter operator to filter the selected nodes. This works with attributes and with elements. The expression "/Employees/Employee[@ID=1]" returns any Employee node under the Employees node that has an ID attribute with the value one. You also can apply filters that just say that an attribute or element with that name needs to be present. For example, the expression "/Employees/Employee[WebAddress]" returns Employee nodes that have a WebAddress node as child. The expression "/Employees/Employee[FirstName='Klaus']" returns the Employee node that has a FirstName node with the value Klaus.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;text() function&lt;/TD&gt;
&lt;TD&gt;The "text()" function refers to the text of the selected node or attribute. The expression "//Employee//text()" does not list all the descendant nodes of all Employee nodes but rather the value for each descendant node. The expression "//Employee/FirstName[text()='Klaus']" lists all FirstName nodes which have a value of Klaus.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;[ ] (collection operator)&lt;/TD&gt;
&lt;TD&gt;When your expression returns more then one node with the same name, you have a collection returned. The expression "//Employee" returns two Employee nodes, which is nothing more than a collection of Employee nodes. You can apply a collection operator and specify which item from the collection you want to select. Keep in mind that the index starts at one. The expression "//Employee[2]" returns the second Employee node. The order of the selected nodes is the same order as in the XML document. You can use the collection operator in any blend, such as "//Employee[1]/LastName", which selects the first Employee node and then from there the LastName node.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;( ) (group operator)&lt;/TD&gt;
&lt;TD&gt;The collection operator can sometimes have some odd side effects. Assume you have two Employee nodes and each has two Job nodes. What does the expression "//Employee/Job[1]" return? It returns the first Job node for each selected Employee node. But, using the group operator allows you to apply explicit precedence to selections. The expression "(//Employee/Job)[4]" first selects all Job nodes for all Employee nodes and from that collection it returns the fourth node. The group operator can only be applied to the top level expression; for example, "//Employees/(Employee/FirstName)" is invalid.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;comment() function&lt;/TD&gt;
&lt;TD&gt;Returns a comment node. The expression "//comment()" returns any comment node in the XML. The expression "/Employees/comment()" returns the comment nodes under the Employees node.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;node() function&lt;/TD&gt;
&lt;TD&gt;XML documents consist of elements, attributes, and their values, each being a node. So, in XPath expressions you can use a node() function instead of a node name or the text() function. It is a generic way to address a node. The expressions "//Employee/JobTitle/node()" and "//Employee/JobTitle/text()" return the same result, the value of both JobTitle nodes. But, "//Employee//node()" will not just return the elements but also the values of each element, because both are nodes.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;| (union or set operator)&lt;/TD&gt;
&lt;TD&gt;Returns the union of one or more location paths. The expression "//LastName | //FirstName" returns all the LastName and FirstName nodes. It preserves the order of the elements as in the XML and does not return any duplicates. The two location paths "//Employee[@ID=1] | //Employee[FirstName='Klaus']" return the same nodes but the union of these two returns just the one unique node.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P&gt;The table does not represent a complete list, but it lists the most basic operators and functions. As you can see from the samples, this already enables you to build fairly complex XPath queries. Keep in mind that the precedence of the operators is the group operator, followed by the filter operator, the child operator, and recursive descendant operator followed by the rest.&lt;BR&gt;&lt;BR&gt;Let's spend a few minutes on a few basic terms commonly used. You have seen that I use the term XPath expression and XPath query interchangeably. An XPath expression is also called a "Location Path," because you are selecting one or more locations in your XML document and, to be able to do so, you specify the path to it. The expression "//Employees/Employee" is a path to certain locations in your XML document you want to select. It is the path to these locations. The "Location Path" consists of "Location Steps."&lt;BR&gt;&lt;BR&gt;&lt;A name=more&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your path has two steps: First, go to the Employees node and then, from there, go to all the Employee nodes. Each "Location Step" consists of an axis, a node-test, and a predicate or filter. The axis defines the relationship between your current location and the next location you specify. When no location is specified (see table below), child is assumed. The node-test is the node you want to select. You provide the name of the node or the wildcard operator for any node. The predicate or filter is any filter you apply by using the filter operator. The expression //child::Employees/child::Employee" is the same as "//Employees/Employee". Let's look closer at some of the most common axes:&lt;/P&gt;
&lt;P&gt;
&lt;TABLE cellSpacing=0 cellPadding=3 border=1&gt;
&lt;TBODY&gt;
&lt;TR vAlign=top&gt;
&lt;TD&gt;&lt;B&gt;Axes&lt;/B&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;B&gt;Description&lt;/B&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;ancestor::&lt;/TD&gt;
&lt;TD&gt;This returns all ancestors of the selected node. The expression "/Employees/Employee/JobTitle/ancestor::*" selects the JobTitle of each Employee node and then returns all its ancestors up to the root, so it returns the Employee node with the ID one, the Employee node with the ID two, and the Employees node itself. This makes it easy to find all ancestors of your nodes. But, you also can look for a specific ancestor; for example, with the expression "//JobTitle[ancestor::Employee/@ID=1]", you select all JobTitle nodes that have an ancestor node Employee with an ID attribute of the value one.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;child::&lt;/TD&gt;
&lt;TD&gt;This axis is the default if none is specified and has the same result as the child operator. For example, the expression "/child::Employees/child::Employee" selects all the Employee nodes in the Employees node.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;self::&lt;/TD&gt;
&lt;TD&gt;This has the same result as the current context operator. The expression "//*/self::JobTitle" first selects all nodes in the XML document and then refers to the current context and from there selects only the nodes of the type JobTitle. The expression "//*/./JobTitle" returns the same result using the current context operator.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;ancestor-or-self::&lt;/TD&gt;
&lt;TD&gt;Same as the ancestor axis, but it includes the current context. The expression "//JobTitle/ancestor-or-self::*" lists both Employee nodes, both JobTitle nodes, and the Employees node. But, on the other hand, the expression "//JobTitle/ancestor::*" does not return the two JobTitle nodes.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;attribute::&lt;/TD&gt;
&lt;TD&gt;The attribute axis returns the same as the attribute operator; it walks the attributes instead of the elements. The expression "//attribute::*" as well as "//@*" return all the attributes in your XML document.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;descendant::&lt;/TD&gt;
&lt;TD&gt;The descendant operator returns the same as the recursive descendant operator. It returns all descendant nodes. The expression "//Employee/descendant::*" as well as "//Employee//*" return all descendant nodes under the two Employee nodes.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;descendant-or-self::&lt;/TD&gt;
&lt;TD&gt;Same as the descendant axis but it includes the current context. So, the expression "//Employee/descendant-or-self::*" lists both Employee nodes, including all its descendant nodes. But, on the other hand, the expression "//Employee/descendant::*" does not return the two Employee nodes.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;following::&lt;/TD&gt;
&lt;TD&gt;Selects all the nodes following the current context node, which includes all siblings (nodes at the same hierarchy level) and its children but not their descendants. The expression "//Employee[@ID=1]/following::*" selects the Employee node with the attribute ID value of one and then returns all its following Employee nodes, in our case only the one with the attribute ID value of two, and its children, but not the descendants of the children.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;following-sibling::&lt;/TD&gt;
&lt;TD&gt;Returns the same as the following axis but includes only siblings and no children and not their descendants. So, the expression "//Employee[@ID=1]/following-sibling::*" returns only the Employee node with the attribute ID value of two.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;preceding::&lt;/TD&gt;
&lt;TD&gt;Selects all the nodes preceding the current context, which includes all siblings (nodes at the same hierarchy level), and its children but not its descendants. The expression "//Employee[@ID=2]/preceding::*" selects the Employee node with the attribute ID value of two and then returns all its preceding Employee nodes&amp;#8212;in our case, only the one with the attribute ID value of one, and its children but not the descendants of the children.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;preceding-sibling::&lt;/TD&gt;
&lt;TD&gt;Returns the same as the preceding axis but includes only siblings and no children and not its descendants. So, the expression "//Employee[@ID=2]/preceding-sibling::*" returns only the Employee node with the attribute ID value of one.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P&gt;The axes give you more control over which nodes you want to select. It makes it easy to find ancestors, descendants, following, and preceding nodes. Unfortunately, you cannot not run XPath queries against an XML document from within the Visual Studio .NET 2003 IDE. The overall support of XPath is rather weak in Visual Studio.&lt;/P&gt;
&lt;P&gt;You can, however, use commercial tools such as XML Spy from Altova (&lt;A href="http://www.altova.com/" target=new&gt;&lt;FONT color=#002c99&gt;http://www.altova.com&lt;/FONT&gt;&lt;/A&gt;), Stylus Studio from Sonic Software (&lt;A href="http://www.stylusstudio.com/" target=new&gt;&lt;FONT color=#002c99&gt;http://www.stylusstudio.com&lt;/FONT&gt;&lt;/A&gt;), or as I use a simple freeware tool called "Visual XPath" (&lt;A href="http://weblogs.asp.net/nleghari/articles/27951.aspx" target=new&gt;&lt;FONT color=#002c99&gt;http://weblogs.asp.net/nleghari/articles/27951.aspx&lt;/FONT&gt;&lt;/A&gt;). It is very useful to use such tools so you can experiment with XPath and easily create the right XPath query you need plus visually verify that you got the expected result. Here are a few more examples to study:&lt;/P&gt;
&lt;H4&gt;Sample 1&lt;/H4&gt;&lt;PRE&gt;/descendant::JobTitle[ancestor::Employee/@ID=2]&lt;/PRE&gt;
&lt;P&gt;Selects all descendant JobTitle nodes that have as an ancestor an Employee node with the attribute ID value of two. The result will be as follows:&lt;/P&gt;&lt;PRE&gt;&amp;lt;JobTitle&amp;gt;
   Sr. Developer
&amp;lt;/JobTitle&amp;gt;
&lt;/PRE&gt;
&lt;H4&gt;Sample 2&lt;/H4&gt;&lt;PRE&gt;&lt;SPAN class=codeComment&gt;//Employee[WebAddress and LastName='Salchner']/attribute::ID&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Selects all descendant Employee nodes that have a WebAddress child node and a LastName child node with the value Salchner. From the result, it selects the ID attribute, which returns the values of the selected attributes. The result returns 1, the value of the selected ID attribute.&lt;/P&gt;
&lt;H4&gt;Sample 3&lt;/H4&gt;&lt;PRE&gt;&lt;SPAN class=codeComment&gt;//JobTitle[ancestor::*/@ID=1]&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Selects all descendant JobTitle nodes that have any ancestor node with an attribute ID value of one. The result is as follows:&lt;/P&gt;&lt;PRE&gt;&amp;lt;JobTitle&amp;gt;
   Sr. Enterprise Architect
&amp;lt;/JobTitle&amp;gt;
&lt;/PRE&gt;
&lt;P&gt;Understanding the base operators, functions, and axes allows you to build very powerful XPath queries and easily select the XML elements, attributes, or nodes you require. In your filter, you can use a number of boolean and comparison expressions as well as string functions. Here is a list of the most common ones:&lt;/P&gt;
&lt;P&gt;
&lt;TABLE id=Table1 cellSpacing=0 cellPadding=3 border=1&gt;
&lt;TBODY&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;&lt;B&gt;Expression or Function&lt;/B&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;B&gt;Description&lt;/B&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;and (logical and)&lt;/TD&gt;
&lt;TD&gt;Allows you to have two or more logical 'and' conditions in your filter. For example, the expression "//Employee[FirstName='Klaus' and LastName='Salchner']" checks for both the FirstName and LastName.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;or (logical or)&lt;/TD&gt;
&lt;TD&gt;Allows you to have two or more logical 'or' conditions in your filter. The expression "//Employee[FirstName='Klaus' or FirstName='Peter']" checks for nodes that have as FirstName either Klaus or Peter.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;= (equal operator)&lt;/TD&gt;
&lt;TD&gt;For example, "//FirstName[.='Klaus']".&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;!= (unequal operator)&lt;/TD&gt;
&lt;TD&gt;For example, "//FirstName[.!='Klaus']".&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;not() (not operator)&lt;/TD&gt;
&lt;TD&gt;For example, "//Employee[not(FirstName='Klaus')]".&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;"&amp;lt;=" or "&amp;amp;lt;=" (less then equal operator)&lt;/TD&gt;
&lt;TD&gt;For example, "//Employee[@ID&amp;lt;=1]".&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;"&amp;lt;" or "&amp;amp;lt;" (less then operator)&lt;/TD&gt;
&lt;TD&gt;For example, "//Employee[@ID&amp;lt;2]".&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;"&amp;gt;=" or "&amp;amp;gt;=" (greater equal operator)&lt;/TD&gt;
&lt;TD&gt;For example, "//Employee[@ID&amp;gt;=2]".&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;"&amp;gt;" or "&amp;amp;gt;" (greater operator)&lt;/TD&gt;
&lt;TD&gt;For example, "//Employee[@ID&amp;gt;2]".&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;position()&lt;/TD&gt;
&lt;TD&gt;Returns the position or index relative to all the selected nodes. The expression "//Employee[position()=1]" returns the first Employee node.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;last()&lt;/TD&gt;
&lt;TD&gt;Returns the position or index of the last of all selected nodes. The expression "//Employee[position()=last()]" returns the last Employee node.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;concat()&lt;/TD&gt;
&lt;TD&gt;Concatenates two strings together. You can specify two string literals or actual node names. The following expression, //Employee[concat(FirstName,LastName)=concat('Klaus','Salchner')], concatenates the FirstName and LastName together and compares them to the concatenated string literals 'Klaus' and 'Salchner'. All matching nodes are returned.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;contains()&lt;/TD&gt;
&lt;TD&gt;Checks whether the first string contains the second string. You can specify node names or string literals. The following expression, "//Employee[contains(FirstName,'Kl')]", returns all nodes containing the string 'Kl' in the FirstName node.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;starts-with()&lt;/TD&gt;
&lt;TD&gt;Checks whether the first string starts with the second string. You can specify node names or string literals. The following expression, "//Employee[starts-with(FirstName,'Kl')]", returns all nodes starting with the string 'Kl' in the FirstName node.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;substring-after()&lt;/TD&gt;
&lt;TD&gt;Checks whether the first string contains the second string and returns the remaining string after the first occurrence. The expression "//Employee[substring-after(FirstName,'Kl')='aus']" first looks whether the string 'Kl is included in the FirstName node and returns the remaining string after the first occurrence. The FirstName node containing 'Klaus' contains the string 'Kl' and the remaining string returned is 'aus'. It selects all nodes that match this criteria.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;substring-before()&lt;/TD&gt;
&lt;TD&gt;Checks whether the first string contains the second string and returns the preceding string before the first occurrence. The expression "//Employee[substring-before(FirstName,'aus')='Kl']" first looks whether the string 'aus is included in the FirstName node and returns the preceding string before the first occurrence. The FirstName node containing 'Klaus' contains the string 'aus' and the preceding string returned is 'Kl'. It selects all nodes which match this criteria.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;substring()&lt;/TD&gt;
&lt;TD&gt;Returns a sub-string starting at the position specified and with the number of characters specified. This allows you to cut out a sub-string from the specified string. You can specify a node or string literal. The expression "//Employee[substring(FirstName,2,3)='lau']" takes the node FirstName and returns a sub-string starting at position two for three characters in length. The FirstName node containing 'Klaus' returns the sub-string 'lau'. It selects all nodes that match this criteria.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR vAlign=top&gt;
&lt;TD noWrap&gt;string-length()&lt;/TD&gt;
&lt;TD&gt;Returns the length of a string. You can give a node name or string literal. The expression "//Employee[string-length(LastName)&amp;gt;=8]" returns all nodes that have a LastName node of greater or equal of eight characters.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P&gt;The table does not contain a complete list but explains the most common expression and functions. For a complete list, please refer to the XPath standard.&lt;BR&gt;&lt;/P&gt;&lt;img src="http://geekswithblogs.net/Dhaka/aggbug/94138.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Dhaka/comments/94138.aspx</wfw:comment>
        <slash:comments>1</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Dhaka/comments/commentRss/94138.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Dhaka/services/trackbacks/94138.aspx</trackback:ping>
    </entry>
    <entry>
        <title>XPath Introduction</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Dhaka/archive/2006/10/15/94137.aspx" />
        <id>http://geekswithblogs.net/Dhaka/archive/2006/10/15/94137.aspx</id>
        <published>2006-10-15T18:22:00-05:00:00</published>
        <updated>2006-10-15T18:22:00Z</updated>
        <content type="html">&lt;STRONG&gt;XPath is a language for finding information in an XML document. XPath is used to navigate through elements and attributes in an XML document.&lt;BR&gt;&lt;BR&gt;&lt;/STRONG&gt;
&lt;H2&gt;What is XPath?&lt;/H2&gt;
&lt;UL&gt;
&lt;LI&gt;XPath is a syntax for defining parts of an XML document 
&lt;LI&gt;XPath uses path expressions to navigate in XML documents 
&lt;LI&gt;XPath contains a library of standard functions 
&lt;LI&gt;XPath is a major element in XSLT 
&lt;LI&gt;XPath is a W3C Standard &lt;/LI&gt;&lt;/UL&gt;
&lt;H2&gt;XPath Path Expressions&lt;/H2&gt;
&lt;P&gt;XPath uses path expressions to select nodes or node-sets in an XML document. These path expressions look very much like the expressions you see when you work with a traditional computer file system.&lt;BR&gt;&lt;/P&gt;
&lt;H2&gt;XPath Standard Functions&lt;/H2&gt;
&lt;P&gt;XPath includes over 100 built-in functions. There are functions for string values, numeric values, date and time comparison, node and QName manipulation, sequence manipulation, Boolean values, and more.&lt;/P&gt;&lt;img src="http://geekswithblogs.net/Dhaka/aggbug/94137.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Dhaka/comments/94137.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Dhaka/comments/commentRss/94137.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Dhaka/services/trackbacks/94137.aspx</trackback:ping>
    </entry>
    <entry>
        <title>X509Chain Class </title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Dhaka/archive/2006/10/15/94136.aspx" />
        <id>http://geekswithblogs.net/Dhaka/archive/2006/10/15/94136.aspx</id>
        <published>2006-10-15T18:18:00-05:00:00</published>
        <updated>2006-10-15T18:18:00Z</updated>
        <content type="html">&lt;P&gt;&lt;B&gt;Namespace:&lt;/B&gt; System.Security.Cryptography.X509Certificates&lt;BR&gt;&lt;B&gt;Assembly:&lt;/B&gt; System (in system.dll)&lt;A name=remarksToggle&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;B&gt;X509Chain&lt;/B&gt; object has a global error status called &lt;A onclick="javascript:TrackThisClick('ctl00_LibFrame_ctl12','ctl00_LibFrame_ctl13',this);" href="http://windowssdk.msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509chain.chainstatus(VS.80).aspx"&gt;&lt;FONT color=#002c99&gt;ChainStatus&lt;/FONT&gt;&lt;/A&gt; that should be used for certificate validation. The rules governing certificate validation are complex, and it is easy to oversimplify the validation logic by ignoring the error status of one or more of the elements involved. The global error status takes into consideration the status of each element in the chain.&lt;BR&gt;&lt;BR&gt;The following code example opens the current user's personal certificate store, allows you to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select.&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;BR&gt;using&lt;/SPAN&gt; System;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Security.Cryptography;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Security.Cryptography.X509Certificates;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.IO;&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; TestX509Chain&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Main(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;[] args)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;//Create new X509 store from local certificate store.&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X509Store store = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; X509Store("MY", StoreLocation.CurrentUser);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadWrite);&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;//Output store information.&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine ("Store Information");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine ("Number of certificates &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; the store: {0}", store.Certificates.Count);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine ("Store location: {0}", store.Location);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine ("Store name: {0} {1}", store.Name, Environment.NewLine);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;//Put certificates from the store into a collection so user can select one.&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X509Certificate2Collection fcollection = (X509Certificate2Collection)store.Certificates;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X509Certificate2Collection collection = X509Certificate2UI.SelectFromCollection(fcollection, "Select an X509 Certificate", "Choose a certificate to examine.", X509SelectionFlag.SingleSelection);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X509Certificate2 certificate = collection[0];&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X509Certificate2UI.DisplayCertificate(certificate);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;//Output chain information of the selected certificate.&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X509Chain ch = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; X509Chain();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ch.Build (certificate);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine ("Chain Information");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ch.ChainPolicy.RevocationMode = X509RevocationMode.Online;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine ("Chain revocation flag: {0}", ch.ChainPolicy.RevocationFlag);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine ("Chain revocation mode: {0}", ch.ChainPolicy.RevocationMode);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine ("Chain verification flag: {0}", ch.ChainPolicy.VerificationFlags);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine ("Chain verification time: {0}", ch.ChainPolicy.VerificationTime);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine ("Chain status length: {0}", ch.ChainStatus.Length);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine ("Chain application policy count: {0}", ch.ChainPolicy.ApplicationPolicy.Count);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine ("Chain certificate policy count: {0} {1}", ch.ChainPolicy.CertificatePolicy.Count, Environment.NewLine);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;//Output chain element information.&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine ("Chain Element Information");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine ("Number of chain elements: {0}", ch.ChainElements.Count);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine ("Chain elements synchronized? {0} {1}", ch.ChainElements.IsSynchronized, Environment.NewLine);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;foreach&lt;/SPAN&gt; (X509ChainElement element &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; ch.ChainElements)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine ("Element issuer name: {0}", element.Certificate.Issuer);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine ("Element certificate valid until: {0}", element.Certificate.NotAfter);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine ("Element certificate is valid: {0}", element.Certificate.Verify ());&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine ("Element error status length: {0}", element.ChainElementStatus.Length);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine ("Element information: {0}", element.Information);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine ("Number of element extensions: {0}{1}", element.Certificate.Extensions.Count, Environment.NewLine);&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ch.ChainStatus.Length &amp;gt; 1)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; (&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; index = 0; index &amp;lt; element.ChainElementStatus.Length; index++)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine (element.ChainElementStatus[index].Status);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine (element.ChainElementStatus[index].StatusInformation);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; store.Close();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;Revoked property&lt;/P&gt;&lt;img src="http://geekswithblogs.net/Dhaka/aggbug/94136.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Dhaka/comments/94136.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Dhaka/comments/commentRss/94136.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Dhaka/services/trackbacks/94136.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Digital Certification X509Certificate C# Asp.net</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Dhaka/archive/2006/10/15/94135.aspx" />
        <id>http://geekswithblogs.net/Dhaka/archive/2006/10/15/94135.aspx</id>
        <published>2006-10-15T18:12:00-05:00:00</published>
        <updated>2006-10-15T18:15:00Z</updated>
        <content type="html">&lt;P class=MsoNormal&gt;&lt;FONT face=Verdana size=2 nd="3"&gt;Any application of cryptography in building a secured infrastructure uses many of encryption, hashing and signature ciphers. In fact all the cryptographic solutions that are available today include a comprehensive infrastructure with many ciphers, extensive security policies, rich tools for creating, deploying and managing secure applications and other integrated set of cryptographic services. One such infrastructure that comes with Windows 2000 is Public Key Infrastructure (PKI).&lt;/FONT&gt; &lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face=Verdana size=2 nd="4"&gt;The challenge for any such PKI is relating the public-key with the entity that owns it, and also the publication and management of public-keys. The standard mechanism to achieve this is digital certification. This part of the article discusses digital certificates and their implementation in FCL and Web Service Enhancements (WSE 1.0) for Microsoft .NET. It also digresses into Windows 2000 PKI. &lt;/FONT&gt; &lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face=Verdana size=2&gt;&lt;STRONG&gt;Digital Certification&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2 nd="5"&gt;Digital certification is an application in which a certification authority signs a special message m, containing the name of user and the users public-key in such a way that any one can verify that the message was signed by no one other than the centralized certification authority.&lt;SPAN style="mso-spacerun: yes"&gt;  &lt;/SPAN&gt;This message m along with its signature is called digital &lt;A class=iAs style="COLOR: darkgreen; BORDER-BOTTOM: darkgreen 1px solid; BACKGROUND-COLOR: transparent; TEXT-DECORATION: underline" href="http://www.c-sharpcorner.com/Code/2003/Jan/DigitalCertIII.asp#" target=_blank itxtdid="2633191"&gt;certificate&lt;/A&gt; or digital id. A typical digital certificate contains the subjects name, subjects public-key, subjects public-key algorithm and parameters, unique id of the certificate, validity period of the certificate, certificate issuer name and the issuers signature.&lt;BR&gt;&lt;FONT face=Verdana size=2 nd="6"&gt;&lt;BR&gt;To understand the need for digital certification, revisit the scenario explained in Digital Signing section of Cryptographic Applications of this article where our fictitious personalities Alice and Bob exchange digitally signed messages between them. In this Alice sends a digitally signed message to Bob; Bob ensures that the message was not altered in transit by verifying the mathematical validity of the signature using the public-key of Alice (PBa). &lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt; &lt;BR&gt;&lt;BR&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;SPAN style="FONT-SIZE: 10pt; mso-bidi-font-size: 12.0pt"&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita27.gif" border=0 v:shapes="_x0000_i1036"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2 nd="7"&gt;Alice signs the message with her private-key (PKa) of signature key-pair and sends the signature along with the message to Bob.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;SPAN style="FONT-SIZE: 10pt; mso-bidi-font-size: 12.0pt"&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita28.gif" border=0 v:shapes="_x0000_i1037"&gt;&lt;BR&gt;&lt;BR&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2 nd="8"&gt;Bob verifies the validity of the signature using Alices public-key (PBa).&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2 nd="9"&gt;The big challenge in this solution is publicizing the Alices public-key.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2&gt;1.How Bob gets Alices public-key?&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2 nd="10"&gt;2.How can Bob be sure that the key he received is Alices public-key and not someone elses?&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2 nd="11"&gt;An apparent quick solution for this problem is Alice handing over her public-key to Bob in a secured manner. But this &lt;SPAN style="mso-bidi-font-size: 8.0pt" nd="12"&gt;presupposes that Alice and Bob have had some form of secured communication prior. Even If Alice publicizes her public-key in this way, it is not scalable. If she needs to have similar secured communication with say 100 more users then this process becomes a nightmare. Also for Bob getting public-key in this way and managing them is a nightmare. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2 nd="13"&gt;If both Bob and Alice can trust some intermediary who in a secured way can bind a public-key to the owner of it, the problem will be solved. Alice can simply ask this intermediary to certify her public key. Bob needs to trust only this intermediary. He can verify that trusted intermediary certified the public-key. Since both Alice and Bob need to trust the public-key with one person, this scales for any number of users. For anyone with whom Alice needs to communicate she can send the same certificate.&lt;SPAN style="mso-spacerun: yes"&gt;  &lt;/SPAN&gt;Also Bob can verify the public-key for all the users who are certified by the intermediary. &lt;I&gt;&lt;SPAN style="mso-bidi-font-size: 10.0pt"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;     &lt;BR&gt;&lt;BR&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN-LEFT: 0.25in"&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita29.gif" border=0 v:shapes="_x0000_i1038"&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita30.gif" border=0 v:shapes="_x0000_i1039"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="TEXT-INDENT: 0.25in"&gt;&lt;FONT face=Verdana size=2&gt; &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="TEXT-INDENT: 0.25in"&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita31.gif" border=0 v:shapes="_x0000_i1040"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="TEXT-INDENT: 0.25in"&gt;&lt;FONT face=Verdana size=2&gt; &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="TEXT-INDENT: 0.25in"&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita32.gif" border=0 v:shapes="_x0000_i1041"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="TEXT-INDENT: 0.25in"&gt;&lt;FONT face=Verdana size=2&gt; &lt;o:p&gt; &lt;/P&gt;
&lt;P class=MsoNormal style="TEXT-INDENT: 0.25in"&gt;&lt;FONT face=Verdana size=2 nd="14"&gt;Alice signs the message with her private-key and sends her certificate along with the message and signature to Bob. Bob verifies the validity of the signature using Alices public-key that he extracts from the Alice certificate issued by c&lt;SPAN style="mso-bidi-font-size: 10.0pt"&gt;ertifying authority &lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H3&gt;&lt;FONT face=Verdana size=2&gt;X 509 Certification &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/H3&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2 nd="15"&gt;There are three certification methods that are commonly used now &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.25in; TEXT-INDENT: 0in"&gt;&lt;FONT face=Verdana size=2&gt;1.Directory Methods (&lt;A href="http://www.itu.int/rec/recommendation.asp?type=folders&amp;lang=e&amp;parent=T-REC-X.509"&gt;X 509&lt;/A&gt; Certificates and CAs)&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.25in; TEXT-INDENT: 0in"&gt;&lt;FONT face=Verdana size=2&gt;2.Referal Methods (&lt;A href="http://www.pgp.com/"&gt;PGP&lt;/A&gt;)&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.25in; TEXT-INDENT: 0in"&gt;&lt;FONT face=Verdana size=2&gt;3.Collabrative Methods (&lt;A href="http://www.skip.org/"&gt;SKIP&lt;/A&gt;)&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="TEXT-INDENT: 0.25in"&gt;&lt;SPAN style="mso-bidi-font-size: 10.0pt"&gt;&lt;FONT face=Verdana size=2&gt; Of these X 509 devised by &lt;A href="http://www.itu.int/home/index.html"&gt;ITU-T&lt;/A&gt; is the de facto standard. &lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2 nd="16"&gt;X 509 digital certificates associates the public-key with the distinguished name, defined by &lt;A href="http://www.cis.ohio-state.edu/cgi-bin/rfc/rfc1308.html"&gt;X 500&lt;/A&gt;, of the user.&lt;/FONT&gt;&lt;/P&gt;
&lt;H4&gt;&lt;FONT face=Verdana size=2&gt;Certificate Chain &lt;SPAN style="mso-bidi-font-size: 10.0pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;P class=MsoNormal style="TEXT-INDENT: 0.25in"&gt;&lt;FONT face=Verdana size=2 nd="17"&gt;&lt;SPAN style="mso-bidi-font-size: 10.0pt"&gt; &lt;/SPAN&gt;X 509 digital certificates are signed messages by themselves, wherein the certifying authority (hereafter referred as CA) is the signer of the message. CA uses public-key of its signature key pair to sign users digital certificate. However this does not solve the Bobs problem of binding the public-key to owner of it. How do Bob bind the public-key of CA to CA? Chicken and Egg Problem? &lt;SPAN style="mso-bidi-font-size: 8.0pt" nd="18"&gt;Bob now needs to find a certificate issued by a superior CA attesting the identity of this CA. By doing this &lt;/SPAN&gt;Bob starts constructing a chain of certificates, each attesting the subordinate CAs identity, terminating in a certificate issued by someone that Bob implicitly trusts. Such a certificate is called a trusted root certificate. Trusted root certificate forms the root of a hierarchy of public-keys/identity bindings that Bob accepts as authentic. The CA that issued the trusted root certificate is called Root-CA, and the one that issued certificate to Alice is called Issuing-CA. All the other CAs between the root and the issuing CAs are called Intermediate-CA. When Bob chooses to explicitly trust a particular trusted root certificate, he is also implicitly trusting all the certificates issued by that trusted root CA, as well as all certificates issued by any subordinate CA certified by the trusted root.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="TEXT-INDENT: 0.25in"&gt;&lt;SPAN style="mso-bidi-font-size: 10.0pt"&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita33.gif" border=0 v:shapes="_x0000_i1042"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H4&gt;&lt;FONT face=Verdana size=2&gt;Certificate Contents&lt;/FONT&gt;&lt;/H4&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0in"&gt;&lt;FONT face=Verdana size=2 nd="19"&gt;In addition to the users distinguished name and public-key, digital certificate also contain other information. Following Picture shows the content of &lt;SPAN style="mso-bidi-font-size: 10.0pt"&gt;Version 1 X 509 digital certificates&lt;/SPAN&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2&gt; &lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita34.gif" border=0 v:shapes="_x0000_i1043"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;SPAN style="mso-bidi-font-size: 10.0pt"&gt;&lt;FONT face=Verdana size=2 nd="20"&gt;Version 2 X 509 digital certificates introduced two more fields,&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2&gt;&lt;B&gt;&lt;SPAN style="mso-bidi-font-size: 10.0pt"&gt;Issuer Unique ID&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-size: 10.0pt"&gt;: &lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-size: 8.0pt" nd="21"&gt;Makes the issuer name unambiguous if it is used by more than one entity.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2&gt;&lt;B&gt;&lt;SPAN style="mso-bidi-font-size: 8.0pt"&gt;Subject &lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-size: 10.0pt"&gt;Unique ID&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-size: 10.0pt"&gt;: &lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-size: 8.0pt" nd="22"&gt;Makes the subject name unambiguous if it is used by more than one entity.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;SPAN style="mso-bidi-font-size: 10.0pt"&gt;&lt;FONT face=Verdana size=2 nd="23"&gt;Version 3 X 509 digital certificates allowed adding any number of custom fields, called Extensions, to the certificate.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;SPAN style="mso-bidi-font-size: 10.0pt"&gt;&lt;FONT face=Verdana size=2 nd="24"&gt;Following pictures shows a Version 3 X 509 digital certificate issued by the Certification &lt;A class=iAs style="COLOR: darkgreen; BORDER-BOTTOM: darkgreen 1px solid; BACKGROUND-COLOR: transparent; TEXT-DECORATION: underline" href="http://www.c-sharpcorner.com/Code/2003/Jan/DigitalCertIII.asp#" target=_blank itxtdid="2390441"&gt;Server&lt;/A&gt; in Windows 2000 Advanced Server.  &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;SPAN style="mso-bidi-font-size: 10.0pt"&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita35.gif" border=0 v:shapes="_x0000_i1044"&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;SPAN style="mso-bidi-font-size: 10.0pt"&gt;&lt;FONT face=Verdana size=2&gt;Following are the details of the certificate&lt;SPAN style="mso-tab-count: 1"&gt;           &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;U&gt;&lt;FONT face=Verdana size=2&gt;Version 1 Fields&lt;/FONT&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2 nd="26"&gt;&lt;B&gt;Version:&lt;/B&gt; &lt;SPAN style="mso-bidi-font-size: 8.5pt"&gt;V3&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="mso-bidi-font-size: 8.5pt"&gt;&lt;BR&gt;Serial Number:&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-size: 8.5pt"&gt; 6106 C4F8 0000 0000 0002&lt;/SPAN&gt;&lt;B&gt;&lt;BR&gt;Valid From:&lt;/B&gt; &lt;SPAN style="mso-bidi-font-size: 8.5pt"&gt;Friday, December 20, 2002 7:55:34 PM&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="mso-bidi-font-size: 8.5pt"&gt;&lt;BR&gt;Valid To:&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-size: 8.5pt"&gt; Monday, December 20, 2004 7:48:02 PM&lt;/SPAN&gt;&lt;B&gt;&lt;BR&gt;Subject:&lt;/B&gt;&lt;SPAN style="mso-bidi-font-size: 8.5pt"&gt; CN = w2k-as-1224.PGVIJAY.com&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="mso-bidi-font-size: 8.5pt"&gt;&lt;BR&gt;Public Key:&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-size: 8.5pt" nd="25"&gt; RSA (1024 bits) 3081 8902 8181 00A5 4F71 CE5C B897 BBB5 DE85 790A E590 DCD5 6720 8B65 A98F 0A56 652E BC60 DF7B 783C 9DF0 373C AFD0 B447 4BAD BF56 C940 164B 534C 4CD9 A602 87B4 EF02 C8CB F9FA 89E2 53CB 350D 6096 416B EB16 E9F8 8DA2 5769 112F 3DE4 28FE 6CF5 9673 8093 A65A 3BB7 C420 9A7E 718E CF64 2725 3E71 F6A7 4E00 9A00 38B8 7F9F FC39 DD0E 9255 437B 5F02 0301 0001&lt;/SPAN&gt;&lt;B&gt;&lt;BR&gt;Issuer:&lt;/B&gt; CN = Pgvijay, OU = pgvijay home, O = pgvijay Inc, L = Stamford, S = ct, C = US, E = &lt;A href="mailto:pgvijay@msn.com"&gt;pgvijay@msn.com&lt;/A&gt;&lt;B&gt;&lt;SPAN style="mso-bidi-font-size: 8.5pt"&gt;&lt;BR&gt;Signature Algorithm:&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-size: 8.5pt"&gt; sha1RSA&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;U&gt;&lt;FONT face=Verdana size=2&gt;Version 2 Fields&lt;/FONT&gt;&lt;/U&gt;&lt;FONT face=Verdana size=2 nd="28"&gt;&lt;B&gt;&lt;SPAN style="mso-bidi-font-size: 8.5pt"&gt;&lt;BR&gt;Subject Key Identifier:&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-size: 8.5pt"&gt; 2377 9A5E EA96 93A3 7409 021E FCDA B713 A368 0C34&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="mso-bidi-font-size: 8.5pt"&gt;&lt;BR&gt;Authority Key Identifier:&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-size: 8.5pt" nd="27"&gt; KeyID=BF9A 4988 5536 A242 7512 9AE2 FC68 CF27 6CA6 C283 &lt;/SPAN&gt;Certificate Issuer: Directory Address: CN=Pgvijay, OU=pgvijay home, O=pgvijay inc, L=Stamford, S=ct, C=US, E=pgvijay@msn.com Certificate Serial Number=6D81 BF9C E657 C88B 42FD A72C 44D3 39E6&lt;A name=_Version_3_Fields&gt;&lt;BR&gt;&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2 nd="30"&gt;&lt;U&gt;Version 3 Fields&lt;/U&gt;&lt;B&gt;&lt;SPAN style="mso-bidi-font-size: 8.5pt"&gt;&lt;BR&gt;Key usage:&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-size: 8.5pt"&gt; Digital Signature, Key Encipherment (A0) &lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-size: 10.0pt"&gt;See the side bar 2.&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="mso-bidi-font-size: 8.5pt"&gt;&lt;BR&gt;Enhanced Key Usage:&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-size: 8.5pt" nd="29"&gt; Client Authentication (1.3.6.1.5.5.7.3.2), Server Authentication (1.3.6.1.5.5.7.3.1)&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="mso-bidi-font-size: 8.5pt"&gt;&lt;BR&gt;Certificate Template:&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-size: 8.5pt"&gt; Domain Controller&lt;/SPAN&gt;&lt;B&gt;&lt;BR&gt;Subject: Alternative Name: &lt;/B&gt;Other Name: 1.3.6.1.4.1.311.25.1=0410 9BF6 C540 6777 CD4C 965F 82D4 ADE4 7440 DNS Name=w2k-as-1224.PGVIJAY.com&lt;/FONT&gt;&lt;B&gt;&lt;FONT face=Verdana size=2&gt;&lt;BR&gt;CRL Distribution Point: &lt;/FONT&gt;&lt;/B&gt;&lt;FONT face=Verdana size=2&gt;&lt;BR&gt;[1]CRL Distribution Point&lt;/FONT&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;FONT face=Verdana size=2&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2&gt;Distribution Point Name:&lt;/FONT&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;FONT face=Verdana size=2&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2&gt;Full Name:&lt;/FONT&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;FONT face=Verdana size=2&gt;&lt;BR&gt;               &lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2 nd="31"&gt;URL=ldap:///CN=Pgvijay,CN=w2k-as-1224,CN=CDP,CN=Public%20Key%20Services,CN=Services,CN=&lt;BR&gt;Configuration,DC=PGVIJAY,DC=com?certificateRevocationList?base?objectclass=cRLDistributionPoint&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2&gt;[2]CRL Distribution Point&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0in"&gt;&lt;FONT face=Verdana size=2&gt;Distribution Point Name:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0in"&gt;&lt;FONT face=Verdana size=2&gt;Full Name:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0in"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;FONT face=Verdana size=2&gt;            &lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2 nd="32"&gt;URL=http://w2k-as-1224.pgvijay.com/CertEnroll/Pgvijay.crl&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0in"&gt;&lt;B&gt;&lt;FONT face=Verdana size=2&gt;Authority Information Access:&lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0in"&gt;&lt;FONT face=Verdana size=2&gt;[1]Authority Info Access&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0in"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;FONT face=Verdana size=2&gt;     &lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2 nd="33"&gt;Access Method=Certification Authority Issuer(1.3.6.1.5.5.7.48.2)&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0in"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;FONT face=Verdana size=2&gt;     &lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2&gt;Alternative Name:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0in"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;FONT face=Verdana size=2&gt;          &lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2 nd="34"&gt;URL=ldap:///CN=Pgvijay,CN=AIA,CN=Public%20Key%20Services,CN=Services,CN=Configuration,DC=PGVIJAY,DC=com?cACertificate?base?objectclass=certificationAuthority&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0in"&gt;&lt;FONT face=Verdana size=2&gt;[2]Authority Info Access&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0in"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;FONT face=Verdana size=2&gt;     &lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2 nd="35"&gt;Access Method=Certification Authority Issuer(1.3.6.1.5.5.7.48.2)&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0in"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;FONT face=Verdana size=2&gt;     &lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2&gt;Alternative Name:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0in"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;FONT face=Verdana size=2&gt;          &lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2 nd="36"&gt;URL=http://w2k-as-1224.pgvijay.com/CertEnroll/w2k-as-1224.PGVIJAY.com_Pgvijay.crt&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0in"&gt;&lt;FONT face=Verdana size=2&gt;&lt;B&gt;Thumbprint Algorithm:&lt;/B&gt; sha1&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0in"&gt;&lt;FONT face=Verdana size=2&gt;&lt;B&gt;Thumbprint:&lt;/B&gt;&lt;SPAN style="mso-bidi-font-size: 8.5pt"&gt; 8C14 83A7 CAAE ED61 DCBE A15E 7E9A B2A0 7713 F138&lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0in"&gt;&lt;FONT face=Verdana size=2&gt; &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN-LEFT: 0.5in"&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita36.gif" border=0 v:shapes="_x0000_i1045"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H4&gt;&lt;FONT face=Verdana size=2&gt;Certificate Revocation Lists &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0in"&gt;&lt;FONT face=Verdana size=2 nd="37"&gt;A certificate revocation list (CRL) is the list of certificates that were revoked by the CA for some reason like the subjects private key being compromised. CA publishes the CRL at well-known places. Certificate issued by the Certificate Server of Windows 2000 PKI has the pointer to CRL also in it as a version 3 extension. &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="TEXT-INDENT: 0.5in"&gt;&lt;FONT face=Verdana size=2&gt;The above &lt;A href="http://www.c-sharpcorner.com/Code/2003/Jan/DigitalCertIII.asp#_Version_3_Fields"&gt;certificate&lt;/A&gt; states that the CRL will be published in&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="TEXT-INDENT: 0.5in"&gt;&lt;FONT face=Verdana size=2&gt;1.Web server (&lt;A href="http://w2k-as-1224.pgvijay.com/CertEnroll/Pgvijay.crl"&gt;http://w2k-as-1224.pgvijay.com/CertEnroll/Pgvijay.crl&lt;/A&gt;)&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="TEXT-INDENT: 0.5in"&gt;&lt;FONT face=Verdana size=2 nd="38"&gt;2.Active directory server (ldap:///CN=Pgvijay,CN=w2k-as-1224,CN=CDP,CN=Public%20Key%20Services,CN=Services,CN=Configuration,&lt;BR&gt; DC=PGVIJAY,DC=com?certificateRevocationList?base?objectclass=cRLDistributionPoint)&lt;/FONT&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&lt;FONT face=Verdana size=2&gt;     &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H4&gt;&lt;FONT face=Verdana size=2&gt;Certificate Trust Lists &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0in"&gt;&lt;FONT face=Verdana size=2 nd="39"&gt;A certificate trust list (CTL) enables controlling the trust of the purpose and of the validity period of certificates that are issued by any external certification authorities (Windows 2000 PKI comes with Certificate Server and this becomes Internal certificate authority in the domain. Any CA that is not part of Windows 2000 domain, like Verisign etc, becomes external certificate authority). Typically, a certification authority issue certificates for a wide variety of purposes, such as &lt;A class=iAs style="COLOR: darkgreen; BORDER-BOTTOM: darkgreen 1px solid; BACKGROUND-COLOR: transparent; TEXT-DECORATION: underline" href="http://www.c-sharpcorner.com/Code/2003/Jan/DigitalCertIII.asp#" target=_blank itxtdid="2739673"&gt;secure e-mail&lt;/A&gt; or client authentication. But in situations when the trust of these certificates is to be limited, a certificate trust list is created. Suppose, for example, a certification authority named Abc CA is capable of issuing certificates for server authentication, client authentication, code signing, and secure e-mail. However, the certificates issued by Abc CA needs to be trusted only for the purpose of client authentication, a certificate trust list that limit the purpose for which certificates issued by Abc CA to client authentication is created. Any certificates issued for another purpose by Abc CA are not accepted for use by any computer to which this certificate trust list is applied. &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H2&gt;&lt;FONT face=Verdana size=2&gt;Digital Certificate Support in CryptoAPI&lt;/FONT&gt;&lt;/H2&gt;
&lt;H3&gt;&lt;FONT face=Verdana size=2&gt;Physical Store&lt;/FONT&gt;&lt;/H3&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2 nd="40"&gt;Physical certificate store provides a grouping of certificates, certificate revocation lists (CRLs), and certificate trust lists (CTLs). Certificate store has only the pointers to the certificates and not the certificate themselves; instead certificates are persisted in permanent storages like file, registry (local or remote machine), active directory server, and smart card etc. &lt;SPAN style="mso-bidi-font-style: italic"&gt;Physical &lt;/SPAN&gt;stores in turn are also located in different physical storages as the certificates. They can also be created on memory for temporary purposes.&lt;SPAN style="mso-spacerun: yes"&gt;  &lt;/SPAN&gt;&lt;A name=_Certificate_Store_Providers&gt;&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H3&gt;&lt;FONT face=Verdana size=2&gt;Certificate Store Providers&lt;/FONT&gt;&lt;/H3&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2&gt;CryptoAPI has&lt;SPAN style="mso-bidi-font-size: 8.0pt" nd="41"&gt; predefined store provider types for different locations where a &lt;/SPAN&gt;physical store can be persisted.&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita37.gif" border=0 v:shapes="_x0000_i1046"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H3&gt;&lt;FONT face=Verdana size=2&gt;Logical Stores &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/H3&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2&gt;Sometime &lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana"&gt;a &lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-size: 8.0pt" nd="42"&gt;certificate might need to be member of several different logical groups. For this a logical collection of physical stores, called logical stores&lt;U&gt;,&lt;/U&gt; is used. Any operation performed on the logical store is performed on the underlying physical stores. For instance, opening the logical store opens all the underlying physical stores, enumerating the certificates in the logical store enumerates all the certificates in all the underlying physical stores etc., An individual physical store can be a member of more than one logical store.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H3&gt;&lt;FONT face=Verdana size=2&gt;System Stores&lt;/FONT&gt;&lt;/H3&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;SPAN style="mso-bidi-font-size: 8.0pt"&gt;&lt;FONT face=Verdana size=2 nd="43"&gt;Microsoft Windows 2000 comes with five predefined logical collection stores, namely MY, CA, TRUST, ROOT and USERDS. These stores are called &lt;B&gt;system stores&lt;/B&gt;. Each of the following system store location has some or all of these system stores; and in addition they can also have other user created logical stores.&lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;SPAN style="mso-bidi-font-size: 8.0pt"&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita38.gif" border=0 v:shapes="_x0000_i1047"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="mso-bidi-font-size: 8.0pt" nd="44"&gt;&lt;SPAN style="mso-spacerun: yes"&gt; &lt;/SPAN&gt;As said before every logical store in each of above locations have associated physical stores. For instance &lt;/SPAN&gt;system stores&lt;SPAN style="mso-bidi-font-size: 8.0pt"&gt; at &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; mso-bidi-font-size: 12.0pt"&gt;Current User&lt;/SPAN&gt; has the following physical store association &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita39.gif" border=0 v:shapes="_x0000_i1048"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;SPAN style="mso-bidi-font-size: 8.0pt"&gt;&lt;FONT face=Verdana size=2 nd="45"&gt;Following picture shows a sample association between MY system store and the physical stores.&lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;SPAN style="mso-bidi-font-size: 8.0pt"&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita40.gif" border=0 v:shapes="_x0000_i1025"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;SPAN style="mso-bidi-font-size: 8.0pt"&gt;&lt;FONT face=Verdana size=2 nd="46"&gt;For more details on the store location please refer &lt;A href="http://msdn.microsoft.com/library/en-us/security/security/system_store_locations.asp"&gt;MSDN&lt;/A&gt;.&lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H3&gt;&lt;FONT face=Verdana size=2 nd="47"&gt;Key Databases in Cryptographic Service Providers (CSP)&lt;/FONT&gt;&lt;/H3&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2 nd="48"&gt;Cryptography Service Providers in CrytpAPI persists the asymmetric key pairs across multiple sessions in a key database. These key databases have multiple key containers, which are identified by unique names. Windows creates a key container for each user of the machine. The key container is named after the user name. All the keys that belong to the user are kept in this container.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;SPAN style="mso-bidi-font-size: 10.0pt"&gt;&lt;FONT face=Verdana size=2 nd="49"&gt;There are usually two key pairs in each container: key-exchange key pair and signature key pair. While the former is used to encrypt session keys, the later is used to create digital signatures. (For more details refer previous parts of this article). &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;SPAN style="mso-bidi-font-size: 10.0pt"&gt;&lt;FONT face=Verdana size=2 nd="50"&gt;Microsoft CSPs stores their key database in two different locations based on the type of the application, interactive standalone applications or non-interactive service applications. While Windows NT keeps the key containers in registry, Windows 2000 keeps them in file. Windows NT keeps key-database under the registry keys HKEY_CURRENT_USER\Software\Microsoft\Cryptography\UserKeys and HKEY_LOCAL_MACHINE\Software \Microsoft\Cryprography\MachineKeys for stand-alone applications and for non-interactive service applications respectively. Windows NT keeps key-database in a file under directories \Documents and settings\&lt;username&gt;\Application Data\Microsoft\Crypto\RSA\&lt;user SID&gt; and \Documents and settings\All Users\Application Data\Microsoft \Crypto\RSA\Machinekeys for stand-alone applications and for non-interactive service applications respectively. &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-size: 8.0pt"&gt;&lt;FONT face=Verdana size=2&gt; &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H2&gt;&lt;FONT face=Verdana size=2&gt;Cryptography Support in Microsoft.Net&lt;/FONT&gt;&lt;SPAN style="mso-bidi-font-size: 8.0pt"&gt;&lt;FONT face=Verdana size=2&gt; &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/H2&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;B&gt;&lt;FONT face=Verdana size=2&gt;System.Security.Cryptography.X509Certificates &lt;/FONT&gt;&lt;/B&gt;&lt;FONT face=Verdana size=2 nd="51"&gt;namespace provides classes to work with X509v3 Digital Certificates. &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2 nd="52"&gt;However the namespace does not have full support to work with digital certificates, for instance there is no support for very important tasks such as&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2 nd="53"&gt;1.Loading certificates from a certificate store.&lt;BR&gt;2.Finding the private-key associated with the public-key of digital certificate, from the key database.&lt;BR&gt;3.Reading X509 Version 2 Fields (Loads a v2 certificate but does not have methods to get the fields)&lt;BR&gt;4.Reading X509 Version 3 Fields (Loads a v3 certificate but does not have methods to get the fields)&lt;BR&gt;5.Working with CRL and CTL.&lt;BR&gt;&lt;BR&gt;However &lt;B&gt;X509Certificate &lt;/B&gt;class provides static methods to load a certificate from a file.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; X509Certificate CreateFromCertFile(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; filename); &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2 nd="54"&gt;Following snippet shows how to load a certificate from file msn.cer/. &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.25in; TEXT-INDENT: 0in"&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita41.gif" border=0 v:shapes="_x0000_i1049"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.25in; TEXT-INDENT: 0in"&gt;&lt;FONT face=Verdana size=2 nd="55"&gt;Following is the output generated by the above snippet. Output is edited for brevity. &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.25in; TEXT-INDENT: 0in"&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita42.gif" border=0 v:shapes="_x0000_i1050"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2 nd="56"&gt;1.2.840.113549.1.1.1 is the OID for RSA. For more details refer &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/security/security/crypt_algorithm_identifier.asp"&gt;MSDN&lt;/A&gt; &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2 nd="57"&gt;Following picture shows the msn.cer certificate used by MSN. The certificate is available as a part of the attached sample. &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;SPAN style="mso-bidi-font-size: 8.0pt"&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita43.gif" border=0 v:shapes="_x0000_i1027"&gt; &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H3&gt;&lt;FONT face=Verdana size=2&gt;Web Service Extensions for Microsoft.Net&lt;/FONT&gt;&lt;B&gt;&lt;FONT face=Verdana size=2&gt; &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/H3&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;B&gt;&lt;FONT face=Verdana size=2&gt;Microsoft.Web.Services.Security.X509 &lt;/FONT&gt;&lt;/B&gt;&lt;FONT face=Verdana size=2 nd="58"&gt;namespace of &lt;A href="http://msdn.microsoft.com/webservices/building/wse/default.aspx"&gt;Web Service Extensions&lt;/A&gt; (WSE 1.0) attempts to bridge the gap between the extensive X509 support in CrytpoAPIs and the limited X509 support in FCL. It has an &lt;B&gt;X509Certificate &lt;/B&gt;class, which derives from the X509Certificate&lt;B&gt; &lt;/B&gt;in the FCL. It also has a class to work with Certificate store &lt;B&gt;X509CertificateStore. &lt;/B&gt;To use WSE a reference to Microsoft.Web.Services.dll should be added to the project. &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2 nd="59"&gt;Microsoft.Web.Services.Security.X509.X509Certificate class has a property to find the associated private key. &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2 nd="60"&gt;Microsoft.Web.Services.Security.X509.X509Certificate first finds the public-key, the asymmetric algorithm of the public-key and the subject name from the certificate. Then it attempts to load the default CSP that can work with the asymmetric key cipher in the certificate. In this sample the public-key cipher is RSA and the key size of 1024 bits (certificate file is attached with the sample). So it attempts to load "Microsoft Enhanced Cryptographic Provider v1.0" CSP using &lt;B&gt;System.Security.Cryptography.RSACryptoServiceProvider&lt;/B&gt;. Then it attempts to load the corresponding private-key from the key container named after the subject-name (in this sample pgvijay) from the CSPs key database. &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2&gt;Following snippet shows how to use it.&lt;/FONT&gt;&lt;B&gt;&lt;FONT face=Verdana size=2&gt; &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;B&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita44.gif" border=0 v:shapes="_x0000_i1026"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;H4&gt;&lt;FONT face=Verdana size=2&gt;Certificate Store in WSE 1.0&lt;/FONT&gt;&lt;/H4&gt;
&lt;P class=MsoBodyTextIndent style="TEXT-INDENT: 0.5in"&gt;&lt;B&gt;&lt;FONT face=Verdana size=2&gt;Microsoft.Web.Services.Security.X509.X509CertificateStore &lt;/FONT&gt;&lt;/B&gt;&lt;FONT face=Verdana size=2 nd="61"&gt;class provides partial CryptoAPI certificate store support. The X509CertificateStore class constructor takes the &lt;A href="http://www.c-sharpcorner.com/Code/2003/Jan/DigitalCertIII.asp#_Certificate_Store_Providers"&gt;store provider&lt;/A&gt;, &lt;A href="http://www.c-sharpcorner.com/Code/2003/Jan/DigitalCertIII.asp#_System_Store_Locations"&gt;store location&lt;/A&gt; and store name.&lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face=Verdana size=2&gt; &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0in"&gt;&lt;FONT face=Verdana size=2 nd="62"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; X509CertificateStore(X509CertificateStore.StoreProvider provider,&lt;SPAN style="mso-spacerun: yes"&gt;  &lt;/SPAN&gt;X509CertificateStore.StoreLocation location,&lt;SPAN style="COLOR: blue"&gt; string&lt;/SPAN&gt; storeName); &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0in"&gt;&lt;FONT face=Verdana size=2 nd="63"&gt;It only supports four store providers, namely system, file, collection and memory; but all the store locations defined by the CryptoAPI. &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H4&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita45.gif" border=0 v:shapes="_x0000_i1028"&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;P class=MsoBodyTextIndent style="TEXT-INDENT: 0.5in"&gt;&lt;FONT face=Verdana size=2 nd="64"&gt;X509CertificateStore class provides methods to search for certificates based on subject name, key identifier and the hash value. Following snippet shows one such code&lt;/FONT&gt;&lt;SPAN style="mso-bidi-font-size: 8.0pt"&gt;&lt;FONT face=Verdana size=2&gt; &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="TEXT-INDENT: 0.5in; mso-layout-grid-align: none"&gt;&lt;I&gt;&lt;SPAN style="mso-bidi-font-size: 10.0pt"&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita46.gif" border=0 v:shapes="_x0000_i1029"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;SPAN style="mso-bidi-font-size: 8.0pt"&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-size: 8.0pt"&gt;&lt;FONT face=Verdana size=2 nd="65"&gt;Following snippet shows how to find the asymmetric key pair when given the subject name of the certificate.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-size: 8.0pt"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&lt;FONT face=Verdana size=2&gt;      &lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent style="TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="mso-bidi-font-size: 8.0pt"&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita47.gif" border=0 v:shapes="_x0000_i1030"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H2&gt;&lt;FONT face=Verdana size=2&gt;Certificate Services in Windows 2000 &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/H2&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2 nd="66"&gt;Windows 2000 Public Key Infrastructure comes with a Certificate Server. To generate a certificate for a user using the certificate server navigate to the CertServ Web Application installed in the CA Server (&lt;A href="http://w2k-as-1224/CertSrv/"&gt;http://w2k-as-1224/CertSrv/&lt;/A&gt;). &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoBodyTextIndent&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita48.jpg" border=0 v:shapes="_x0000_i1031"&gt;&lt;SPAN style="mso-spacerun: yes"&gt; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="TEXT-INDENT: 0.25in"&gt;&lt;FONT face=Verdana size=2 nd="67"&gt;Select Request a certificate in this page and say Next. &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="TEXT-INDENT: 0.25in"&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita49.jpg" border=0 v:shapes="_x0000_i1032"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="TEXT-INDENT: 0.25in"&gt;&lt;FONT face=Verdana size=2 nd="68"&gt;Select Advanced request in this page and say Next &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="TEXT-INDENT: 0.25in"&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita50.jpg" border=0 v:shapes="_x0000_i1033"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face=Verdana size=2&gt; Select &lt;SPAN style="FONT-FAMILY: Arial" nd="69"&gt;Submit a certificate request to this CA using a form. In this page and say Next&lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="TEXT-INDENT: 0.25in"&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita51.jpg" border=0 v:shapes="_x0000_i1034"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="TEXT-INDENT: 0.25in"&gt;&lt;FONT face=Verdana size=2 nd="70"&gt;Fill up the page as shown above. This creates a 1024 bits RSA key-pair and stores the key set in the key container BobKeys of the CSP Microsoft Base Cryptographic Provider v1.0. The key set can be user as both signature key pair and key exchange key pair. &lt;o:p&gt; &lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="TEXT-INDENT: 0.25in"&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.c-sharpcorner.com/Code/2003/Jan/Digita52.jpg" border=0 v:shapes="_x0000_i1035"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="TEXT-INDENT: 0.25in"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;FONT face=Verdana size=2 nd="71"&gt;Selecting Install this certificate will install the certificate in the default store of the local machine.&lt;/FONT&gt;&lt;/SPAN&gt; &lt;BR&gt;&lt;BR&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&lt;SYSTEM.WEB&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;img src="http://geekswithblogs.net/Dhaka/aggbug/94135.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Dhaka/comments/94135.aspx</wfw:comment>
        <slash:comments>2</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Dhaka/comments/commentRss/94135.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Dhaka/services/trackbacks/94135.aspx</trackback:ping>
    </entry>
    <entry>
        <title>LDAP Get Info from Active Directory</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Dhaka/archive/2006/10/15/94129.aspx" />
        <id>http://geekswithblogs.net/Dhaka/archive/2006/10/15/94129.aspx</id>
        <published>2006-10-15T17:54:00-05:00:00</published>
        <updated>2006-10-15T17:57:00Z</updated>
        <content type="html">&lt;DIV&gt;To retrive all imformation from avtive directory through ldap protocol&lt;/DIV&gt;
&lt;DIV&gt; &lt;/DIV&gt;
&lt;DIV&gt; &lt;/DIV&gt;
&lt;DIV&gt;using objX509Cert = System.Security.Cryptography.X509Certificates; &lt;BR&gt;&lt;BR&gt;string filter = "mail=*"; &lt;BR&gt;xd = lcl.LDAPInfo(filter); &lt;BR&gt;&lt;BR&gt;public XmlDocument LDAPInfo(string filter) &lt;BR&gt;{ &lt;BR&gt;XmlDocument xd = new XmlDocument(); &lt;BR&gt;string domainAndUsername = string.Empty; &lt;BR&gt;string userName = string.Empty; &lt;BR&gt;string passWord = string.Empty; &lt;BR&gt;string Sur = ""; &lt;BR&gt;string Cn = ""; &lt;BR&gt;string Name = ""; &lt;BR&gt;string GName = ""; &lt;BR&gt;string DGname = ""; &lt;BR&gt;string Member = ""; &lt;BR&gt;string Init = ""; &lt;BR&gt;string Postal = ""; &lt;BR&gt;string Loc = ""; &lt;BR&gt;string C = ""; &lt;BR&gt;string Mobile = ""; &lt;BR&gt;string HomePh = ""; &lt;BR&gt;string Title = ""; &lt;BR&gt;string Co= ""; &lt;BR&gt;string State = ""; &lt;BR&gt;string eMail = ""; &lt;BR&gt;&lt;BR&gt;string Password = ""; &lt;BR&gt;string SAM = ""; &lt;BR&gt;&lt;BR&gt;string MemOf = ""; &lt;BR&gt;string UID = ""; &lt;BR&gt;string Desc = ""; &lt;BR&gt;string UserCert = ""; &lt;BR&gt;string UserCertName = ""; &lt;BR&gt;string certno = ""; &lt;BR&gt;string certString64=""; &lt;BR&gt;&lt;BR&gt;Boolean chkpass = false; &lt;BR&gt;AuthenticationTypes at = AuthenticationTypes.Anonymous; &lt;BR&gt;StringBuilder sbb = new StringBuilder(); &lt;BR&gt;&lt;BR&gt;&lt;BR&gt;//****Connecting to LDAP active directory &lt;BR&gt;domainAndUsername = @"LDAP://YourDomain/c=CH"; &lt;BR&gt;userName = "username" ; &lt;BR&gt;passWord = "password"; &lt;BR&gt;//at = AuthenticationTypes.Secure; &lt;BR&gt;&lt;BR&gt;//Create the object necessary to read the info from the LDAP directory &lt;BR&gt;DirectoryEntry entry = new DirectoryEntry(domainAndUsername,userName, passWord,at); &lt;BR&gt;DirectorySearcher mySearcher = new DirectorySearcher(entry); &lt;BR&gt;SearchResultCollection results; &lt;BR&gt;mySearcher.Filter = filter; &lt;BR&gt;&lt;BR&gt;try &lt;BR&gt;{ &lt;BR&gt;results = mySearcher.FindAll(); &lt;BR&gt;&lt;BR&gt;if (results.Count &gt; 0) &lt;BR&gt;{ &lt;BR&gt;sbb.Append(""); &lt;BR&gt;foreach(SearchResult resEnt in results) &lt;BR&gt;{ &lt;BR&gt;sbb.Append(""); &lt;BR&gt;ResultPropertyCollection propcoll=resEnt.Properties; &lt;BR&gt;//sbb.Append("" + propcoll.PropertyNames.Count+""); &lt;BR&gt;Sur = ""; &lt;BR&gt;Cn = ""; &lt;BR&gt;Name = ""; &lt;BR&gt;GName = ""; &lt;BR&gt;DGname = ""; &lt;BR&gt;Member = ""; &lt;BR&gt;Init = ""; &lt;BR&gt;Postal = ""; &lt;BR&gt;Loc = ""; &lt;BR&gt;C = ""; &lt;BR&gt;Mobile = ""; &lt;BR&gt;HomePh = ""; &lt;BR&gt;Title = ""; &lt;BR&gt;Co = ""; &lt;BR&gt;State = ""; &lt;BR&gt;Password = ""; &lt;BR&gt;SAM = ""; &lt;BR&gt;MemOf = ""; &lt;BR&gt;UID = ""; &lt;BR&gt;Desc = ""; &lt;BR&gt;UserCert = ""; &lt;BR&gt;UserCertName = ""; &lt;BR&gt;certString64=""; &lt;BR&gt;//string vCardn; &lt;BR&gt;&lt;BR&gt;StringBuilder strBMails = new StringBuilder(); &lt;BR&gt;StringBuilder strBCert = new StringBuilder(); &lt;BR&gt;&lt;BR&gt;foreach(string key in propcoll.PropertyNames) &lt;BR&gt;{ &lt;BR&gt;string values = ""; &lt;BR&gt;if (propcoll[key].Count &gt; 0) &lt;BR&gt;values = propcoll[key][0].ToString(); &lt;BR&gt;&lt;BR&gt;#region Switch &lt;BR&gt;switch (key) &lt;BR&gt;{ &lt;BR&gt;case "sn": &lt;BR&gt;Sur = values.ToString(); &lt;BR&gt;break; &lt;BR&gt;case "cn": &lt;BR&gt;Cn = values.ToString(); &lt;BR&gt;break; &lt;BR&gt;case "name": &lt;BR&gt;Name = values.ToString(); &lt;BR&gt;break; &lt;BR&gt;case "givenname": &lt;BR&gt;GName = values.ToString(); &lt;BR&gt;break; &lt;BR&gt;case "distinguishedname": &lt;BR&gt;DGname = values.ToString(); &lt;BR&gt;break; &lt;BR&gt;case "member": &lt;BR&gt;Member = values.ToString(); &lt;BR&gt;break; &lt;BR&gt;case "initials": &lt;BR&gt;Init = values.ToString(); &lt;BR&gt;break; &lt;BR&gt;case "postalcode": &lt;BR&gt;Postal = values.ToString(); &lt;BR&gt;break; &lt;BR&gt;case "l": &lt;BR&gt;Loc = values.ToString(); &lt;BR&gt;break; &lt;BR&gt;case "c": &lt;BR&gt;C = values.ToString(); &lt;BR&gt;break; &lt;BR&gt;case "mobile": &lt;BR&gt;Mobile = values.ToString(); &lt;BR&gt;break; &lt;BR&gt;case "homephone": &lt;BR&gt;HomePh = values.ToString(); &lt;BR&gt;break; &lt;BR&gt;case "title": &lt;BR&gt;Title = values.ToString(); &lt;BR&gt;break; &lt;BR&gt;case "co": &lt;BR&gt;Co = values.ToString(); &lt;BR&gt;break; &lt;BR&gt;case "st": &lt;BR&gt;State = values.ToString(); &lt;BR&gt;break; &lt;BR&gt;case "mail": &lt;BR&gt;BMails.Append(""); &lt;BR&gt;foreach (object valuess in propcoll[key]) &lt;BR&gt;{ &lt;BR&gt;eMail = valuess.ToString(); &lt;BR&gt;strBMails.Append("" + valuess.ToString() + ""); &lt;BR&gt;} &lt;BR&gt;strBMails.Append(""); &lt;BR&gt;break; &lt;BR&gt;case "password": &lt;BR&gt;strPassword = values.ToString(); &lt;BR&gt;break; &lt;BR&gt;case "samaccountname": &lt;BR&gt;strSAM = values.ToString(); &lt;BR&gt;break; &lt;BR&gt;case "memberof": &lt;BR&gt;strMemOf = values.ToString(); &lt;BR&gt;break; &lt;BR&gt;case "uid": &lt;BR&gt;strUID = values.ToString(); &lt;BR&gt;break; &lt;BR&gt;case "description": &lt;BR&gt;strDesc = values.ToString(); &lt;BR&gt;break; &lt;BR&gt;case "usercertificate;binary": &lt;BR&gt;strBCert.Append(""); &lt;BR&gt;foreach (object valuess in propcoll[key]) &lt;BR&gt;{ &lt;BR&gt;FileStream fs = File.Create("./tempcer1.cer"); &lt;BR&gt;BinaryWriter bw = new BinaryWriter(fs); &lt;BR&gt;bw.Write((byte[])valuess); &lt;BR&gt;bw.Close(); &lt;BR&gt;&lt;BR&gt;objX509Cert.X509Certificate myCert = objX509Cert.X509Certificate.CreateFromCertFile("./tempcer1.cer"); &lt;BR&gt;&lt;BR&gt;&lt;BR&gt;strBCert.Append("" + myCert.GetSerialNumberString() + ""); &lt;BR&gt;strBCert.Append("" + myCert.GetName() + ""); &lt;BR&gt;strBCert.Append("" + myCert.GetExpirationDateString() + ""); &lt;BR&gt;&lt;BR&gt;strcertno = myCert.GetSerialNumberString(); &lt;BR&gt;FileInfo fi = new FileInfo("./tempcer1.cer"); &lt;BR&gt;if (File.Exists(myCert.GetSerialNumberString() + ".cer")) &lt;BR&gt;File.Delete(myCert.GetSerialNumberString() + ".cer"); &lt;BR&gt;fi.MoveTo(myCert.GetSerialNumberString() + ".cer"); &lt;BR&gt;&lt;BR&gt;string cerPath = System.Web.HttpContext.Current.Server.MapPath("./Certificate/"); &lt;BR&gt;if (File.Exists(cerPath + myCert.GetSerialNumberString() + ".cer")) &lt;BR&gt;File.Delete(cerPath + myCert.GetSerialNumberString() + ".cer"); &lt;BR&gt;fi.CopyTo(cerPath + myCert.GetSerialNumberString() + ".cer"); &lt;BR&gt;chkpass = true; &lt;BR&gt;&lt;BR&gt;} &lt;BR&gt;strBCert.Append(""); &lt;BR&gt;break; &lt;BR&gt;} &lt;BR&gt;#endregion &lt;BR&gt;&lt;BR&gt;} &lt;BR&gt;sbb.Append("" + strSur + ""); &lt;BR&gt;sbb.Append("" + strCn + ""); &lt;BR&gt;sbb.Append("" + strName + ""); &lt;BR&gt;sbb.Append(strBMails); &lt;BR&gt;sbb.Append(strBCert); &lt;BR&gt;sbb.Append("" + strGName + ""); &lt;BR&gt;sbb.Append("" + strGName + ""); &lt;BR&gt;sbb.Append("" + strMember + ""); &lt;BR&gt;sbb.Append("" + strInit + ""); &lt;BR&gt;sbb.Append("" + strPostal + ""); &lt;BR&gt;sbb.Append("" + strLoc + ""); &lt;BR&gt;sbb.Append("" + strC + ""); &lt;BR&gt;sbb.Append("" + strMobile + ""); &lt;BR&gt;sbb.Append("" + strHomePh + ""); &lt;BR&gt;sbb.Append(""); &lt;BR&gt;sbb.Append("" + strCo + ""); &lt;BR&gt;sbb.Append("" + strState + ""); &lt;BR&gt;sbb.Append("" +strPassword + ""); &lt;BR&gt;sbb.Append("" + strSAM + ""); &lt;BR&gt;sbb.Append("" + strMemOf + ""); &lt;BR&gt;sbb.Append("" + strUID + ""); &lt;BR&gt;sbb.Append("" + strDesc + ""); &lt;BR&gt;sbb.Append(""); &lt;BR&gt;&lt;BR&gt;&lt;BR&gt;} &lt;BR&gt;sbb.Append(""); &lt;BR&gt;&lt;BR&gt;&lt;BR&gt;xd.LoadXml(sbb.ToString()); &lt;BR&gt;return xd; &lt;BR&gt;} &lt;BR&gt;} &lt;BR&gt;catch (Exception ex) &lt;BR&gt;{ &lt;BR&gt;string msg = ex.Message; &lt;BR&gt;} &lt;BR&gt;sbb.Append("No"); &lt;BR&gt;xd.LoadXml(sbb.ToString()); &lt;BR&gt;return xd; &lt;BR&gt;}&lt;/DIV&gt;&lt;img src="http://geekswithblogs.net/Dhaka/aggbug/94129.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Dhaka/comments/94129.aspx</wfw:comment>
        <slash:comments>2</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Dhaka/comments/commentRss/94129.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Dhaka/services/trackbacks/94129.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Create .VCF File(outlook contact file) with C#</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Dhaka/archive/2006/10/15/94130.aspx" />
        <id>http://geekswithblogs.net/Dhaka/archive/2006/10/15/94130.aspx</id>
        <published>2006-10-15T17:55:00-05:00:00</published>
        <updated>2006-10-15T17:55:00Z</updated>
        <content type="html">&lt;DIV&gt;This is code of to create vcf card on the fly &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;//sdBuild is string builder &lt;BR&gt;&lt;BR&gt;sdBuild.Append("N:" + strCn + System.Environment.NewLine); &lt;BR&gt;sdBuild.Append("FN:" + strCn +System.Environment.NewLine); &lt;BR&gt;//// encoding to base 64 &lt;BR&gt;certString64 = certString64 + System.Environment.NewLine + "KEY;X509;ENCODING=BASE64:" + System.Environment.NewLine; &lt;BR&gt;certString64 = certString64 + Convert.ToBase64String((byte[])valuess) + System.Environment.NewLine; &lt;BR&gt;//// encoding to base 64 ends here &lt;BR&gt;sdBuild.Append(certString64); &lt;BR&gt;&lt;BR&gt;sdBuild.Append(System.Environment.NewLine+"ORG: None;"+System.Environment.NewLine); &lt;BR&gt;sdBuild.Append("TITLE:" + strTitle +System.Environment.NewLine); &lt;BR&gt;sdBuild.Append("NOTE;ENCODING=QUOTED-PRINTABLE:This is a note associated with this"+System.Environment.NewLine); &lt;BR&gt;sdBuild.Append("contact=0D=0A"+System.Environment.NewLine); &lt;BR&gt;sdBuild.Append("TEL;WORK;VOICE:"+System.Environment.NewLine); &lt;BR&gt;sdBuild.Append("TEL;HOME;VOICE:" + strHomePh +System.Environment.NewLine); &lt;BR&gt;sdBuild.Append("TEL;CELL;VOICE:" + strMobile +System.Environment.NewLine); &lt;BR&gt;sdBuild.Append("TEL;WORK;"+System.Environment.NewLine); &lt;BR&gt;sdBuild.Append("ADR;WORK:;;" + strState + ";" + strCo +System.Environment.NewLine); &lt;BR&gt;sdBuild.Append("LABEL;WORK;ENCODING=QUOTED-PRINTABLE:" + strCo +System.Environment.NewLine); &lt;BR&gt;sdBuild.Append("751234 =0D=0AUnited States of America" +System.Environment.NewLine); &lt;BR&gt;sdBuild.Append("URL:"+System.Environment.NewLine); &lt;BR&gt;sdBuild.Append("URL:"+System.Environment.NewLine); &lt;BR&gt;sdBuild.Append("EMAIL;PREF;INTERNET:" + streMail +System.Environment.NewLine); &lt;BR&gt;sdBuild.Append("REV:"+System.Environment.NewLine); &lt;BR&gt;sdBuild.Append("END:VCARD");&lt;/DIV&gt;&lt;img src="http://geekswithblogs.net/Dhaka/aggbug/94130.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Dhaka/comments/94130.aspx</wfw:comment>
        <slash:comments>1</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Dhaka/comments/commentRss/94130.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Dhaka/services/trackbacks/94130.aspx</trackback:ping>
    </entry>
    <entry>
        <title>How to change the ower of tables in Microsoft SQL Server database</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Dhaka/archive/2006/10/15/94131.aspx" />
        <id>http://geekswithblogs.net/Dhaka/archive/2006/10/15/94131.aspx</id>
        <published>2006-10-15T17:55:00-05:00:00</published>
        <updated>2006-10-15T17:55:00Z</updated>
        <content type="html">&lt;DIV&gt;To do this, execute the following command on every table &lt;BR&gt;&lt;BR&gt;exec sp_changeobjectowner '?????', 'DBO' - where ????? is the name of your database table. &lt;BR&gt;&lt;BR&gt;Also below is the stored procedure through which you can change the owner for every table in the database. &lt;BR&gt;&lt;BR&gt;EXEC sp_changeobjectowner @oldownerplusobject, @new &lt;BR&gt;&lt;BR&gt;create procedure _ChangeObjectOwner (@type varchar(1),@old varchar(20),@new &lt;BR&gt;&lt;BR&gt;varchar(20)) &lt;BR&gt;&lt;BR&gt;as &lt;BR&gt;&lt;BR&gt;declare @ObjectName varchar(100) &lt;BR&gt;&lt;BR&gt;declare @oldownerplusobject varchar(50) begin declare Cursor_Object cursor for select [name] from sysobjects where type=@type and xtype=@type open Cursor_Object FETCH NEXT FROM Cursor_Object INTO @ObjectName WHILE @@FETCH_STATUS = 0 begin &lt;BR&gt;&lt;BR&gt;set @oldownerplusobject=@old+'.'+@ObjectName &lt;BR&gt;&lt;BR&gt;EXEC sp_changeobjectowner @oldownerplusobject, @new &lt;BR&gt;&lt;BR&gt;print 'Permission Changed for ' + @oldownerplusobject +' to ' + @new + ' : &lt;BR&gt;&lt;BR&gt;Process Done' &lt;BR&gt;&lt;BR&gt;FETCH NEXT FROM Cursor_Object INTO @ObjectName end close Cursor_Object deallocate Cursor_Object end &lt;BR&gt;&lt;BR&gt;exec _ChangeObjectOwner 'p','xxx','yyy'&lt;/DIV&gt;&lt;img src="http://geekswithblogs.net/Dhaka/aggbug/94131.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Dhaka/comments/94131.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Dhaka/comments/commentRss/94131.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Dhaka/services/trackbacks/94131.aspx</trackback:ping>
    </entry>
    <entry>
        <title>How to change the ower of tables in Microsoft SQL Server database</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Dhaka/archive/2006/10/15/94128.aspx" />
        <id>http://geekswithblogs.net/Dhaka/archive/2006/10/15/94128.aspx</id>
        <published>2006-10-15T17:54:00-05:00:00</published>
        <updated>2006-10-15T17:54:00Z</updated>
        <content type="html">&lt;DIV&gt;To do this, execute the following command on every table &lt;BR&gt;&lt;BR&gt;exec sp_changeobjectowner '?????', 'DBO' - where ????? is the name of your database table. &lt;BR&gt;&lt;BR&gt;Also below is the stored procedure through which you can change the owner for every table in the database. &lt;BR&gt;&lt;BR&gt;EXEC sp_changeobjectowner @oldownerplusobject, @new &lt;BR&gt;&lt;BR&gt;create procedure _ChangeObjectOwner (@type varchar(1),@old varchar(20),@new &lt;BR&gt;&lt;BR&gt;varchar(20)) &lt;BR&gt;&lt;BR&gt;as &lt;BR&gt;&lt;BR&gt;declare @ObjectName varchar(100) &lt;BR&gt;&lt;BR&gt;declare @oldownerplusobject varchar(50) begin declare Cursor_Object cursor for select [name] from sysobjects where type=@type and xtype=@type open Cursor_Object FETCH NEXT FROM Cursor_Object INTO @ObjectName WHILE @@FETCH_STATUS = 0 begin &lt;BR&gt;&lt;BR&gt;set @oldownerplusobject=@old+'.'+@ObjectName &lt;BR&gt;&lt;BR&gt;EXEC sp_changeobjectowner @oldownerplusobject, @new &lt;BR&gt;&lt;BR&gt;print 'Permission Changed for ' + @oldownerplusobject +' to ' + @new + ' : &lt;BR&gt;&lt;BR&gt;Process Done' &lt;BR&gt;&lt;BR&gt;FETCH NEXT FROM Cursor_Object INTO @ObjectName end close Cursor_Object deallocate Cursor_Object end &lt;BR&gt;&lt;BR&gt;exec _ChangeObjectOwner 'p','xxx','yyy'&lt;/DIV&gt;&lt;img src="http://geekswithblogs.net/Dhaka/aggbug/94128.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Dhaka/comments/94128.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Dhaka/comments/commentRss/94128.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Dhaka/services/trackbacks/94128.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Clear Project List from Start Page</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Dhaka/archive/2006/10/15/94127.aspx" />
        <id>http://geekswithblogs.net/Dhaka/archive/2006/10/15/94127.aspx</id>
        <published>2006-10-15T17:51:00-05:00:00</published>
        <updated>2006-10-15T17:51:00Z</updated>
        <content type="html">&lt;DIV&gt;Here is a nice tips to clear the Recent project list or File list from Visual Studio .Net &lt;BR&gt;Run--&amp;gt; RegEdit and navigate to &lt;BR&gt;&lt;BR&gt;HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\&lt;YOUR&gt;\ProjectMRUList delete unnecessary list. &lt;BR&gt;&lt;BR&gt;similarly for FileMRuList. &lt;BR&gt;&lt;BR&gt;Make sure not disturb other key from the registry.&lt;/DIV&gt;&lt;img src="http://geekswithblogs.net/Dhaka/aggbug/94127.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Dhaka/comments/94127.aspx</wfw:comment>
        <slash:comments>1</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Dhaka/comments/commentRss/94127.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Dhaka/services/trackbacks/94127.aspx</trackback:ping>
    </entry>
</feed>
