Solved

Get data from ActiveDirectory with C#...

Posted on 2007-03-17
2
1,598 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

815 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

8 Experts available now in Live!

Get 1:1 Help Now