473,762 Members | 8,011 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataSet and SearchResultCol lection

Ryo
Hello !

I want to know if there are an easy way to put a SearchResultCol lection
(resulting of a query on Active Directory) into a DataSet ?
Thanks;
Nov 19 '05 #1
5 4603

Is the search result collection a DataSet Type or something else ?
"Ryo" <Ry*@discussion s.microsoft.com > wrote in message
news:9F******** *************** ***********@mic rosoft.com...
Hello !

I want to know if there are an easy way to put a SearchResultCol lection
(resulting of a query on Active Directory) into a DataSet ?
Thanks;

Nov 19 '05 #2
Well, it wouldn't be too hard to simply create datatables and load data rows
into it using a little loop - the code should be less than 1 page.

--

- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.ma.../13/63199.aspx
-------------------------------------------------------------------------------------------

"Ryo" <Ry*@discussion s.microsoft.com > wrote in message
news:9F******** *************** ***********@mic rosoft.com...
Hello !

I want to know if there are an easy way to put a SearchResultCol lection
(resulting of a query on Active Directory) into a DataSet ?
Thanks;

Nov 19 '05 #3
Ryo
I found an example with 3 foreach loop to do waht you say.
But I also found this
(http://216.239.59.104/search?q=cache...ataset&hl=fr):
using System;

using System.Collecti ons;

using System.Data;

using System.Data.Ole Db;
class ADSql

{

static void Main(string[] args)

{

//set the OLEDB provider for Active Directory

OleDbConnection oledb = new
OleDbConnection ("Provider=ADsD SOObject;");

oledb.Open();
//set attribute description list

string searchAttrs = "distinguishedN ame, objectCategory" ;
//set an ADsPath for the search base

string searchBase = "'LDAP://DC=isqre,DC=net '";
//set filter

string searchFilter = "objectClass='u ser'";
//build SQL query string

string searchQuery = "SELECT " + searchAttrs + " FROM " +
searchBase + " WHERE " + searchFilter;
OleDbDataAdapte r oleDA = new OleDbDataAdapte r(searchQuery,
oledb);
//object that will cache the data retrieved from AD

DataSet oleDS = new DataSet();
//retrieve data from AD

oleDA.Fill(oleD S,"obj");

oledb.Dispose() ;

oleDA.Dispose() ;

foreach (DataRow r in oleDS.Tables["obj"].Rows)

{ //process the result

Console.WriteLi ne("-->");

for (int i = 0; i < r.ItemArray.Len gth; i++)

Console.WriteLi ne(" {0}",r.ItemArra y[i].ToString());

}

oleDS.Dispose() ;

}

}

What do you think of this solution ?
What about performance ?

"Sahil Malik [MVP]" wrote:
Well, it wouldn't be too hard to simply create datatables and load data rows
into it using a little loop - the code should be less than 1 page.

--

- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.ma.../13/63199.aspx
-------------------------------------------------------------------------------------------

"Ryo" <Ry*@discussion s.microsoft.com > wrote in message
news:9F******** *************** ***********@mic rosoft.com...
Hello !

I want to know if there are an easy way to put a SearchResultCol lection
(resulting of a query on Active Directory) into a DataSet ?
Thanks;


Nov 19 '05 #4
Thank you Ryo .. that will do just great :)
--

- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.ma.../13/63199.aspx
----------------------------------------------------------------------------

"Ryo" <Ry*@discussion s.microsoft.com > wrote in message
news:07******** *************** ***********@mic rosoft.com...
I found an example with 3 foreach loop to do waht you say.
But I also found this
(http://216.239.59.104/search?q=cache...ataset&hl=fr):
using System;

using System.Collecti ons;

using System.Data;

using System.Data.Ole Db;
class ADSql

{

static void Main(string[] args)

{

//set the OLEDB provider for Active Directory

OleDbConnection oledb = new
OleDbConnection ("Provider=ADsD SOObject;");

oledb.Open();
//set attribute description list

string searchAttrs = "distinguishedN ame, objectCategory" ;
//set an ADsPath for the search base

string searchBase = "'LDAP://DC=isqre,DC=net '";
//set filter

string searchFilter = "objectClass='u ser'";
//build SQL query string

string searchQuery = "SELECT " + searchAttrs + " FROM " +
searchBase + " WHERE " + searchFilter;
OleDbDataAdapte r oleDA = new OleDbDataAdapte r(searchQuery,
oledb);
//object that will cache the data retrieved from AD

DataSet oleDS = new DataSet();
//retrieve data from AD

oleDA.Fill(oleD S,"obj");

oledb.Dispose() ;

oleDA.Dispose() ;

foreach (DataRow r in oleDS.Tables["obj"].Rows)

{ //process the result

Console.WriteLi ne("-->");

for (int i = 0; i < r.ItemArray.Len gth; i++)

Console.WriteLi ne("
{0}",r.ItemArra y[i].ToString());

}

oleDS.Dispose() ;

}

}

What do you think of this solution ?
What about performance ?

"Sahil Malik [MVP]" wrote:
Well, it wouldn't be too hard to simply create datatables and load data
rows
into it using a little loop - the code should be less than 1 page.

--

- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.ma.../13/63199.aspx
-------------------------------------------------------------------------------------------

"Ryo" <Ry*@discussion s.microsoft.com > wrote in message
news:9F******** *************** ***********@mic rosoft.com...
> Hello !
>
> I want to know if there are an easy way to put a SearchResultCol lection
> (resulting of a query on Active Directory) into a DataSet ?
> Thanks;


Nov 19 '05 #5
Ryo
Hum, that's not so great...
Perhaps I'm bad with Active Directory but I can't found how to list all user
from it....
"Sahil Malik [MVP]" wrote:
Thank you Ryo .. that will do just great :)
--

- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.ma.../13/63199.aspx
----------------------------------------------------------------------------

"Ryo" <Ry*@discussion s.microsoft.com > wrote in message
news:07******** *************** ***********@mic rosoft.com...
I found an example with 3 foreach loop to do waht you say.
But I also found this
(http://216.239.59.104/search?q=cache...ataset&hl=fr):
using System;

using System.Collecti ons;

using System.Data;

using System.Data.Ole Db;
class ADSql

{

static void Main(string[] args)

{

//set the OLEDB provider for Active Directory

OleDbConnection oledb = new
OleDbConnection ("Provider=ADsD SOObject;");

oledb.Open();
//set attribute description list

string searchAttrs = "distinguishedN ame, objectCategory" ;
//set an ADsPath for the search base

string searchBase = "'LDAP://DC=isqre,DC=net '";
//set filter

string searchFilter = "objectClass='u ser'";
//build SQL query string

string searchQuery = "SELECT " + searchAttrs + " FROM " +
searchBase + " WHERE " + searchFilter;
OleDbDataAdapte r oleDA = new OleDbDataAdapte r(searchQuery,
oledb);
//object that will cache the data retrieved from AD

DataSet oleDS = new DataSet();
//retrieve data from AD

oleDA.Fill(oleD S,"obj");

oledb.Dispose() ;

oleDA.Dispose() ;

foreach (DataRow r in oleDS.Tables["obj"].Rows)

{ //process the result

Console.WriteLi ne("-->");

for (int i = 0; i < r.ItemArray.Len gth; i++)

Console.WriteLi ne("
{0}",r.ItemArra y[i].ToString());

}

oleDS.Dispose() ;

}

}

What do you think of this solution ?
What about performance ?

"Sahil Malik [MVP]" wrote:
Well, it wouldn't be too hard to simply create datatables and load data
rows
into it using a little loop - the code should be less than 1 page.

--

- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.ma.../13/63199.aspx
-------------------------------------------------------------------------------------------

"Ryo" <Ry*@discussion s.microsoft.com > wrote in message
news:9F******** *************** ***********@mic rosoft.com...
> Hello !
>
> I want to know if there are an easy way to put a SearchResultCol lection
> (resulting of a query on Active Directory) into a DataSet ?
> Thanks;


Nov 19 '05 #6

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

Similar topics

12
9619
by: hykim | last post by:
Hello, everyone. according to MSDN, there is any constructor of System.DirectoryServices.SearchResultCollection Class. if I implement DirectorySearcher.FindAll() method by myself, then how can I instanciate SearchResultCollection Class. more clearly, a SearchResult object is created, at the inside of FindAll() method, then how can I put this object into the SearchResultCollection object. there is any method releated to input operation.
5
5412
by: Mike | last post by:
I need to expand the DataSet class by inheriting from it and adding functions that work on the data in the tables. However, since I can't upcast how can I get my base DataSet object assigned an actual DataSet? e.g. public class MyDataSet : DataSet { // can't do, no valid DataSet constructor
2
3384
by: John Holmes | last post by:
I have a web interface where the user types in ID's one at a time. After an ID is typed in, a button is clicked and the button click event has code that does a query and returns a data reader and then appends the data to a dataset that is built in the Page_Load code in the if(!isPostBack) block. When I try to add a row in the button click event code I get an error saying that "Object reference not set to an instance of an object". I'm...
0
1294
by: mg | last post by:
SearchResultCollection resultCollection = LDAPsearcher.FindAll() SearchResult resultArray resultArray = new SearchResult resultCollection.CopyTo(resultArray,0) resultCollection.Count is But many fewer than N items appear in resultArra How can I get all N items to appear in resultArray?
0
2123
by: mg | last post by:
SearchResultCollection resultCollection = LDAPsearcher.FindAll(); SearchResult resultArray; resultArray = new SearchResult; resultCollection.CopyTo(resultArray,0); resultCollection.Count is N But many fewer than N items appear in resultArray How can I get all N items to appear in resultArray?
3
1214
by: Paul D. Fox | last post by:
I would like to read from Active Directory and populate a dataset to be passed in a Web Service. I can get the data from AD just fine, but can I populate a dataset with these values and do a "Return dataSetName" in my web service?
22
25602
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to compile. <WebMethod()> _ Public Function VerifySku(ByVal skus As XmlDataDocument) As DataSet Test program : Dim cartSet As DataSet cartSet = ws.VerifySku(cartSet)
0
1058
by: Bmack500 | last post by:
I'm getting an error when I try to access the properties in oResult, stating: "System.DirectoryServices.SearchResultCollection.Properties is not accessible in this context because it is 'private'". I don't understand why, since I've passed it as a parameter to the sub. Thanks in advance for any help. Here's the entire (unfinished) sub: Sub insertADRecords(ByVal strCurrOU As String, ByVal oResult As SearchResultCollection) Dim iIndex1...
1
2012
by: nscarnati | last post by:
I have 2 containers with objects. The veterans container contains unique objects. Each of those objects can have 1 or more corresponding card objects in the cards container. VeteranCN is formatted (SSN-LastName) CardsCN is formatted (SSN-LastName-# OR SSN-LastName-#CNFblahblahblah) (the # is the card number) I have the following code, which searches a container for objects. It creates the value that will be used for the next card...
0
9554
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9378
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10137
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9927
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9812
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8814
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6640
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.