Searching the domain with WinNT Provider in ASP.NET

  • Thread starter Matthias Mohr via .NET 247
  • Start date
M

Matthias Mohr via .NET 247

Hello,

I'm trying to get Users that belong to a group with the WinNT Provider in an ASP.NET environment.
I found several examples to do this under ASP using the GetObject-Method (GetObject("WinNT//:Domain/...).
But how does it work in VB.NET?
Can I use the GetObject-Method, or is the usage of DirectoryServices or ADSI the right way?An example please.
Matthias
 
N

Natty Gur

Hi,

you can use WMI :

Add reference to System.Management.dll.
using System.Management;

....

string myDomain = "ChangeTo_DomainName";
string theUser = "ChangeTo_UserName";
string query = "SELECT * FROM Win32_GroupUser " +
"WHERE PartComponent = \"Win32_UserAccount.Domain='" + myDomain +
"',Name='" + theUser + "'\"";
SelectQuery selectQuery = new SelectQuery(query);
ManagementObjectSearcher searcher = new
ManagementObjectSearcher(selectQuery);

foreach( ManagementObject obj in searcher.Get())
{
Console.WriteLine(obj.GetPropertyValue("GroupComponent"));
}
Console.ReadLine();


Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)52-8888377


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top