473,464 Members | 1,729 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

get local and domain members from local group?

Can anyone suggest how to get the local and domain members from a local
group. The C# code is running from an ASP.NET 2.0 webpage.
The following code only returns the local members and not the domain
members as well.

//Start of Code

public string[] GetLocalGroups(string strComputer, string strUser,
string strPswd)
{
DirectoryEntry oComputer;
try
{
if (strUser == "" && strPswd == "")
oComputer = new DirectoryEntry("WinNT://" + strComputer);
else
oComputer = new DirectoryEntry("WinNT://" + strComputer,
strUser, strPswd);
}
catch (Exception)
{
return null;
}

string strOut = "";

DirectoryEntries ds = oComputer.Children;
foreach (DirectoryEntry group in ds)
{
if (group.SchemaClassName.Equals("Group"))
{
if (strOut != "")
strOut += ";";
//strOut += child.Properties["Name"].Value + "\t" +
child.Properties["Description"].Value;
strOut += group.Properties["Name"].Value;

DirectoryEntry oGroup;
try
{
oGroup = new DirectoryEntry("WinNT://" +
strComputer + "/" + group.Properties["Name"].Value, strUser, strPswd,
AuthenticationTypes.Secure);
}
catch (Exception)
{
return null;
}

foreach (object obj in
(IEnumerable)oGroup.Invoke("members"))
{
using (DirectoryEntry user = new DirectoryEntry(obj))
{
strOut += ";\t" + user.Name;

}
}
}
}

string[] arrGroups = null;

if (strOut != "")
{
arrGroups = strOut.Split(';');
}
return (arrGroups);
}

// End Of Code

Thanks
Andres
May 25 '06 #1
0 1190

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Clifford Heath | last post by:
We've set up an SQL Server 2000 (build 8.0.761 - I think that's SP3) access control scenario like the one described in this article:...
5
by: Rocky | last post by:
Hi, I have a webform, with 2 textboxs and a submit button. In the text box1, i enter a username and in textbox2 I enter the computer name. Both the username and computer name is in active...
5
by: Rocky | last post by:
Hi, I have a webform, with 2 textboxs and a submit button. In the text box1, i enter a username and in textbox2 I enter the computer name. Both the username and computer name is in active...
4
by: shashank kadge | last post by:
hi all, i am trying to get local admin users and groups on a windows server. here is the C# code that i am using...
5
by: Michael Howes | last post by:
I'm writing a utility to manage a machines *local* accounts in c# I am getting all the users in a specific Group just fine but when I want to get some of the information on each user from their...
8
by: Michael Howes | last post by:
I have some code that manages local user logins. When I create a new user I want to set the password to expire every x days and the number of failed login attempts before the account is...
2
by: antem | last post by:
I receive only members from domain global goup in wich my NT-Account is too. If domain global group belongs to a foreigner domain i get no members. Perhaps I will not be able cause I got not enaugh...
0
by: Uli Netzer | last post by:
Hi all, I'm trying to add a user from another domain (domain trust and rights are there) to a group in our domain. It's a domain local security group. I get the following errors: The server...
2
by: newVBNETuser | last post by:
I want to get the follow vbScript to work in VB.NET Set objRun = CreateObject("wscript.Shell") strUserName = objRun.ExpandEnvironmentStrings("%USERNAME%") Dim strComputer, member, strUsername,...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.