Hi John,
From your description and the VB code snippet, you're going to use C# to
perform ADSI query on some domain computer's properties. As far as I know,
in .net, ADSI programming is provided by the System.DirectoryServices
namespace. And for accessing ADSI object, you can use the "DirectoryEntry"
class. Here is the C# code snippt that help query the certain domain
computer and loop its properties:
===============
static void RunADSI()
{
DirectoryEntry en = new DirectoryEntry();
en.Path = "WinNT://mydomain/mycomputer";
foreach (string key in en.Properties.PropertyNames)
{
Console.WriteLine("{0}: {1}",key,
en.Properties[key].Value);
}
}
==============
the following ,knowledge base article provide the same information:
#How to access ADSI objects in Visual C#
http://support.microsoft.com/kb/315716
If you want more information and code about ADSI query in .net/c#, I
suggest you have a look at the following ADSI query tool, you can get more
ideas from its code:
#BeaverTail (written entirely in C#)
http://adsi.mvps.org/adsi/CSharp/beavertail.html
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments
and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach
the
most efficient resolution. The offering is not appropriate for
situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are
best
handled working with a dedicated Microsoft Support Engineer by
contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
Reply-To: "John" <
[email protected]>
From: "John" <
[email protected]>
Subject: ADSI script implement in C#
Date: Wed, 28 May 2008 17:15:00 -0700
Hi, gurus,
How can I implement the following feature in C#:
Set objGroup = GetObject("WinNT://" & strComputer & "/" & strGroup & ",
group")
For Each objMember In objGroup.Members
WScript.Echo vbCrLf & " Name: " & objMember.Name
Next
Thanks!
John