Solved

Get data from ActiveDirectory with C#...

Posted on 2007-03-17
2
1,596 Views
Last Modified: 2008-01-09
Hi,
I need to retrieve data from ActiveDirectory (AD is new for me).
There is a code which return a DataSet from the AD (which was writen by someone else).
----------------------------------------------------------------------------------------
            public static DataSet ExecuteDataset(string strSql)
            {
                  OleDbConnection con;
                  OleDbDataAdapter adapter;
                  DataSet ds = new DataSet();

                  con = new OleDbConnection("Provider=ADSDSOObject;User ID=" + PriviligeUser + ";Password=" + PriviligeUserPass + ";Encrypt Password=True;ADSI Flag=1");
                  adapter = new OleDbDataAdapter(strSql, con);
                  adapter.Fill(ds);
                  return ds;
            }
----------------------------------------------------------------------------------------
Lets say i need to get all the users that the ID Number (is there a field by that name in the AD??) is not NULL.
What is the right SQL statment that i have to pass to that function in order to get what i need??
(Is there a table? i meen - what table name do i need to write - SELECT FROM ???......)
Thanks
0
Comment
Question by:udir
2 Comments
 
LVL 15

Accepted Solution

by:
stanscott2 earned 500 total points
ID: 18741370
Hi, this is really more than can be answered in a few questions.  Fortunately, the 15 Seconds site sets it all out very clearly here:  http://www.15seconds.com/issue/020730, "Accessing Active Directory Through the .NET Framework".

This article also includes a lot of downloadable code you can snap in -- it provides a wrapper class so that you can easily work with Active Directory user information.
0
 
LVL 1

Author Comment

by:udir
ID: 18742923
OK
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem with SqlConnection 5 123
Default parameter problem in C# 3 27
cs.Designer Issue(2) 2 23
C# Error - Add Failed 12 53
Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now