ADSI WinNT:// provider

  • Thread starter Thread starter Thomaz
  • Start date Start date
T

Thomaz

In VB, I can write the following code to get the list of
users and groups in the domain ASIA. How do I do the same
in C#

Set objContainer = GetObject("WinNT://ASIA")
objContainer.Filter = Array("user", "group")
For Each user In objContainer
List1.AddItem user.Name
Next

Thanks and Regards,
Thomaz
 
using System.DirectoryServices;

DirectoryEntry objContainer = new DirectoryEntry("WinNT://ASIA");
objContainer.Children.SchemaFilter.Add("group");
objContainer.Children.SchemaFilter.Add("user");
foreach(DirectoryEntry objItem in objContainer.Children) {
List1.AddItem(objItem.Properties["cn"][0].ToString());
}

From the top of my head.


Arild
 
System.DirectoryServices.DirectoryEntry entryRoot
= new System.DirectoryServices.DirectoryEntry
("WinNT://danny-4649bwcv8", null, null,
AuthenticationTypes.None );
try
{

System.DirectoryServices.DirectoryEntries
userEntries = entryRoot.Children;
foreach
(System.DirectoryServices.DirectoryEntry user in
userEntries)
{
if
(user.SchemaClassName.Equals("User"))

Console.WriteLine(user.Name);
}
}
catch
(System.Runtime.InteropServices.COMException e)
{
Console.WriteLine
( "Error " + e);
}
 
System.DirectoryServices.DirectoryEntry entryRoot
= new System.DirectoryServices.DirectoryEntr
("WinNT://danny-4649bwcv8", null, null,
AuthenticationTypes.None )
tr


System.DirectoryServices.DirectoryEntries
userEntries = entryRoot.Children
foreac
(System.DirectoryServices.DirectoryEntry user in
userEntries

i
(user.SchemaClassName.Equals("User")

Console.WriteLine(user.Name)


catch
(System.Runtime.InteropServices.COMException e
{
Console.WriteLin
( "Error " + e)

-----Original Message----
In VB, I can write the following code to get the list of
users and groups in the domain ASIA. How do I do the same
in C
objContainer.Filter = Array("user", "group"
For Each user In objContaine
List1.AddItem user.Nam
Nex
Thoma




Print | Copy URL of this post



.. .


Contact Us | Rules of Conduct
©2004 Microsoft Corporation. All rights reserved. Terms of Use | Privacy Statement
 
Back
Top