Populating fields from Active Directory in asp.net -- Urgent!

J

Jay

I have an asp.net application that needs to fill a series of checkboxes with
usernames from a particular group in Active Directory.

Could someone please point me in the right direction in regards to a snippet
of code or a link to where I might info on this? I've checked msdn and can
find nothing definate.

Thanks in advance,

Jay
 
K

Kevin Spencer

Start with System.DirectoryServices.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
A

A. Elamiri

This is basic code that will list out all the user name. I would advise to
also look into the Filter property of the DirectorySearcher
Of course you would have to change the Response.Write's to whatever or
however you want to output the data retreived
I hope this helps!

DirectoryEntry de = new
DirectoryEntry(ActiveDirectoryQuery,Username,Password);
DirectorySearcher ds = new DirectorySearcher(de);
try{
SearchResultCollection src = ds.FindAll();
foreach(SearchResult sr in src){
Response.Write(sr.Properties["samaccountname"][0].ToString();
}
}
catch(Exception ex){
Response.Write(ex.Message);
}
 
J

Jay

Thanks very much the snippet, I can now search my AD structure and filter,
etc without a problem but I've run into one more snag:

Must I use a specific username and password to access my AD or can I somehow
use the already authenticated user credentials? Obviously I can populate
the Username using iPrincipal but how can I tell it to use its associated
password??

Thanks again in advance,

Jay


A. Elamiri said:
This is basic code that will list out all the user name. I would advise to
also look into the Filter property of the DirectorySearcher
Of course you would have to change the Response.Write's to whatever or
however you want to output the data retreived
I hope this helps!

DirectoryEntry de = new
DirectoryEntry(ActiveDirectoryQuery,Username,Password);
DirectorySearcher ds = new DirectorySearcher(de);
try{
SearchResultCollection src = ds.FindAll();
foreach(SearchResult sr in src){
Response.Write(sr.Properties["samaccountname"][0].ToString();
}
}
catch(Exception ex){
Response.Write(ex.Message);
}

--
Abdellah Elamiri
.net Developer
Efficacy through simplicity


Jay said:
I have an asp.net application that needs to fill a series of checkboxes with
usernames from a particular group in Active Directory.

Could someone please point me in the right direction in regards to a snippet
of code or a link to where I might info on this? I've checked msdn and can
find nothing definate.

Thanks in advance,

Jay
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top