473,385 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to get all AD attirbutes, group/user data with C# web app?

Hi All,

I am new for Active Directory. Is there any successful example codes for getting all Active Directory attribute names, group data and user information data with C# under ASP.NET 2.0?


Thanks advance
Jul 13 '07 #1
1 3039
radcaesar
759 Expert 512MB
Use System.DirectoryServices namespace.

Here is sample code.

string loginPath="WinNT://"+Environment.MachineName+",computer";
System.DirectoryServices.DirectoryEntry AD = new
System.DirectoryServices.DirectoryEntry(loginPath) ;
System.Collections.ArrayList users = new System.Collections.ArrayList();
System.Collections.ArrayList groups = new System.Collections.ArrayList();
System.Collections.ArrayList services = new
System.Collections.ArrayList();
foreach(System.DirectoryServices.DirectoryEntry dir in AD.Children)
{
if(dir.SchemaClassName=="User")
{
users.Add(dir);
}
if (dir.SchemaClassName=="Group")
{
groups.Add(dir);
}
}
for (int i=0; i<users.Count; i++)
{

this.cboUsers.Items.Add(((System.DirectoryServices .DirectoryEntry)((users[i]
))).Name );
}
for (int i=0; i<groups.Count; i++)
{

this.cboGroups.Items.Add(((System.DirectoryService s.DirectoryEntry)((groups[
i]))).Name );
}
Jul 13 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip...
0
by: Mikolaj J | last post by:
Witam, szukając w dokumentacji mysqla odpowiedzi na moje pytanie trafiłem na taki przykład: SELECT user, MAX(salary) as max_sel FROM tmp GROUP BY user HAVING max_sel = MAX(salary); I...
2
by: Tom Loach | last post by:
Our system administrator set up an NT server group in order to allow our users to login to our application via https to our sql server. The group appears as a User in SQL Server when you look at...
1
by: TimG | last post by:
Hello, I am putting together a row level security plan for our sales database. I will give a brief description of the method I am thinking of using to give you an idea of how I will need to be...
0
by: Rob | last post by:
I need to allow a user with the default "Full Data User" permissions on the front-end database to relink to a table in a backend to which he has the same permissions. (I'd like to do read, update,...
0
by: Johnny Drama | last post by:
Hi, My WinForms-based application occasionally reads/writes data from/to the user's profile directory. I use the following logic to determine where the user's profile directory is located: ...
0
by: Lester Knutsen | last post by:
A two-day IBM Informix and DB2 User Group Technical Conference - Friday and Saturday, December 8-9, 2006 We are very please to announce our Keynote Speakers...
0
by: godsmustbcrazy | last post by:
Here is my problem. Brand new SQL Server 2005 Installation 1. Create a database "Test" 2. Create a database user "Domain\user" and set user mapping to "Test" with datareader, datawriter...
2
by: ADNet77 | last post by:
Hi All, I am new for Active Directory. Is there any example codes for getting all Active Directory attribute names, group data and user information data with C#? Thanks advance,
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.