home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / QuickStart / howto / doc / adread.aspx next >
Encoding:
Text File  |  2000-05-16  |  4.7 KB  |  85 lines

  1.  
  2. <!-- #include virtual="/quickstart/howto/include/header.inc" -->
  3.  
  4. <h4>How Do I...Access Active Directory?</h4>
  5.  
  6. <div class="indent" style="width:660">
  7. <p class="MsoNormal"><font face="Tahoma" size="1">Active Directory Service
  8. Interfaces (ADSI) accesses the capabilities of directory services from different
  9. network providers in a distributed computing environment, to present a single
  10. set of directory service interfaces for managing network resources.
  11. Administrators and developers can use ADSI services to enumerate and manage the
  12. resources in a directory service, no matter which network environment contains
  13. the resource. Use Active Directory to perform common administrative tasks, such
  14. as locating resources throughout the distributed computing environment.</font></p>
  15. <p class="MsoNormal"><span style="mso-fareast-font-family: Times New Roman; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"><font size="1" face="Tahoma">This
  16. sample illustrates how to locate resources in the Active Directory. </font></span><span style="FONT-SIZE: 8pt; FONT-FAMILY: Tahoma; mso-bidi-font-size: 10.0pt">It's
  17. a small console application that can be run from a command prompt. The
  18. application takes one command line argument. The first argument has to be a
  19. valid path to an active directory entry.<O:P>
  20.  </O:P>
  21. </span></p>
  22. <p class="Text"><span style="FONT-SIZE: 8pt; FONT-FAMILY: Tahoma; mso-bidi-font-size: 10.0pt">Try
  23. running the following command substituting the path for a valid Active Directory
  24. path for your particular network:<O:P>
  25.  </O:P>
  26. </span></p>
  27. <p class="MsoNormal" style="MARGIN-LEFT: 0.5in"><font face="Courier New" size="2"><span style="COLOR: blue; mso-bidi-font-size: 12.0pt">>
  28. ADRead.exe "LDAP://DC=Microsoft,DC=COM"</span></font></p>
  29. <p class="MsoNormal"><font face="Tahoma" size="1">In its simplest form, reading
  30. from the Active Directory involves:<o:p>
  31. </o:p>
  32. </font></p>
  33. <font face="Tahoma" size="1">1. Creating a new DirectoryEntry:</font>
  34. <blockquote>
  35.   <p class="MsoNormal"><span style="mso-bidi-font-size: 12.0pt"><font face="Courier New" size="2" color="#0000FF">DirectoryEntry
  36.   entry=new DirectoryEntry(path);</font><font face="Tahoma" size="1"><o:p>
  37.   </o:p>
  38.   </font></span></p>
  39. </blockquote>
  40. <p class="MsoNormal"><font face="Tahoma" size="1"> 2. Reading the
  41. information from the Active Directory and printing it to the screen:</font></p>
  42. <blockquote>
  43.   <p class="MsoNormal" style="word-spacing: 0; margin-top: 0; margin-bottom: 0"><span style="mso-bidi-font-size: 12.0pt"><font face="Courier New" size="2" color="#0000FF">foreach(DirectoryEntryProperty
  44.   objP in entry.Properties){<o:p>
  45.   </o:p>
  46.   </font></span></p>
  47.   <p class="MsoNormal" style="word-spacing: 0; margin-top: 0; margin-bottom: 0"><span style="mso-bidi-font-size: 12.0pt"><font face="Courier New" size="2" color="#0000FF">   
  48.   Console.Write(objP.Name + " = ");<o:p>
  49.   </o:p>
  50.   </font></span></p>
  51.   <p class="MsoNormal" style="word-spacing: 0; margin-top: 0; margin-bottom: 0"><span style="mso-bidi-font-size: 12.0pt"><font face="Courier New" size="2" color="#0000FF">   
  52.   foreach(Object objValue in objP.Values) <o:p>
  53.   </o:p>
  54.   </font></span></p>
  55.   <p class="MsoNormal" style="word-spacing: 0; margin-top: 0; margin-bottom: 0">    <font face="Courier New" size="2" color="#0000FF"><span style="mso-bidi-font-size: 12.0pt">   </span></font>    
  56.   <font face="Courier New" size="2" color="#0000FF"><span style="mso-bidi-font-size: 12.0pt">Console.Write(objValue
  57.   + ", ");</span></font></p>
  58.   <p class="MsoNormal" style="word-spacing: 0; margin-top: 0; margin-bottom: 0"><font face="Courier New" size="2" color="#0000FF"><span style="mso-bidi-font-size: 12.0pt">}</span></font><span style="mso-bidi-font-size: 12.0pt"><font face="Courier New" size="2" color="#0000FF"><o:p>
  59.   </o:p>
  60.   </font></span></p>
  61. </blockquote>
  62.  
  63. </div>
  64.  
  65. <h4>Example</h4>
  66.  
  67. <p>
  68. <div class="indent">
  69. <a target="_blank" href="/quickstart/howto/samples/Services/DirectoryServices/ADRead">
  70. <img style="border-color:black" border=1 src="/quickstart/images/genicon.gif"><br>
  71. </a>
  72. <div class="caption">ADRead.exe</div><br>
  73. [<a target="_blank" href="/quickstart/howto/samples/Services/DirectoryServices/ADRead">View Sample</a>] | 
  74. [<a target="_blank" href="/quickstart/util/srcview.aspx?path=/quickstart/howto/samples/Services/DirectoryServices/ADRead/ADRead.src">View Source</a>]<p>
  75. </div>
  76.  
  77. <h4>Source Code</h4>
  78.  
  79. <div class="code">
  80. <xmp>
  81. <!-- #include virtual="/quickstart/howto/samples/Services/DirectoryServices/ADRead/ADRead.cs" -->
  82. </xmp>
  83. </div>
  84.  
  85. <!-- #include virtual="/quickstart/howto/include/footer.inc" -->