You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: xml/System.DirectoryServices/DirectorySearcher.xml
+21-12Lines changed: 21 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -546,19 +546,28 @@ SearchResultCollection res = src.FindAll();
546
546
The following example shows how to use the <xref:System.DirectoryServices.DirectorySearcher.AttributeScopeQuery%2A> property with the member attribute to get the members of a group. It then prints out the first and last names of the members and their telephone numbers.
547
547
548
548
```csharp
549
+
using System;
549
550
using System.DirectoryServices;
550
-
DirectoryEntry group = new DirectoryEntry("LDAP://CN=MyGroup, …");
551
-
DirectorySearcher src = new DirectorySearcher(group "(&(objectClass=user)(objectCategory=Person))");
552
-
src.AttributeScopedQuery = "member";
553
-
src.PropertiesToLoad.Add("sn");
554
-
src.PropertiesToLoad.Add("givenName");
555
-
src.PropertiesToLoad.Add("telephoneNumber");
556
-
foreach(SearchResult res in src.FindAll())
557
-
{
558
-
Console.WriteLine("…");
559
-
}
560
-
```
561
-
551
+
552
+
public class Example
553
+
{
554
+
public static void Main()
555
+
{
556
+
DirectoryEntry group = new DirectoryEntry("LDAP://CN=MyGroup", …);
557
+
DirectorySearcher src = new DirectorySearcher("(&(objectClass=user)(objectCategory=Person))");
558
+
src.AttributeScopeQuery = "member";
559
+
src.PropertiesToLoad.Add("sn");
560
+
src.PropertiesToLoad.Add("givenName");
561
+
src.PropertiesToLoad.Add("telephoneNumber");
562
+
563
+
foreach(SearchResult res in src.FindAll())
564
+
{
565
+
Console.WriteLine("…");
566
+
}
567
+
}
568
+
}
569
+
```
570
+
562
571
]]></format>
563
572
</remarks>
564
573
<exceptioncref="T:System.ArgumentException">The <seecref="P:System.DirectoryServices.DirectorySearcher.SearchScope" /> property is set to a value other than <seecref="F:System.DirectoryServices.SearchScope.Base" />.</exception>
0 commit comments