473,385 Members | 1,597 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.

DataSet and SearchResultCollection

Ryo
Hello !

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

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

I want to know if there are an easy way to put a SearchResultCollection
(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*@discussions.microsoft.com> wrote in message
news:9F**********************************@microsof t.com...
Hello !

I want to know if there are an easy way to put a SearchResultCollection
(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.Collections;

using System.Data;

using System.Data.OleDb;
class ADSql

{

static void Main(string[] args)

{

//set the OLEDB provider for Active Directory

OleDbConnection oledb = new
OleDbConnection("Provider=ADsDSOObject;");

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

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

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

string searchFilter = "objectClass='user'";
//build SQL query string

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

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

oleDA.Fill(oleDS,"obj");

oledb.Dispose();

oleDA.Dispose();

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

{ //process the result

Console.WriteLine("-->");

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

Console.WriteLine(" {0}",r.ItemArray[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*@discussions.microsoft.com> wrote in message
news:9F**********************************@microsof t.com...
Hello !

I want to know if there are an easy way to put a SearchResultCollection
(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*@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.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.Collections;

using System.Data;

using System.Data.OleDb;
class ADSql

{

static void Main(string[] args)

{

//set the OLEDB provider for Active Directory

OleDbConnection oledb = new
OleDbConnection("Provider=ADsDSOObject;");

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

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

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

string searchFilter = "objectClass='user'";
//build SQL query string

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

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

oleDA.Fill(oleDS,"obj");

oledb.Dispose();

oleDA.Dispose();

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

{ //process the result

Console.WriteLine("-->");

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

Console.WriteLine("
{0}",r.ItemArray[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*@discussions.microsoft.com> wrote in message
news:9F**********************************@microsof t.com...
> Hello !
>
> I want to know if there are an easy way to put a SearchResultCollection
> (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*@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.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.Collections;

using System.Data;

using System.Data.OleDb;
class ADSql

{

static void Main(string[] args)

{

//set the OLEDB provider for Active Directory

OleDbConnection oledb = new
OleDbConnection("Provider=ADsDSOObject;");

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

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

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

string searchFilter = "objectClass='user'";
//build SQL query string

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

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

oleDA.Fill(oleDS,"obj");

oledb.Dispose();

oleDA.Dispose();

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

{ //process the result

Console.WriteLine("-->");

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

Console.WriteLine("
{0}",r.ItemArray[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*@discussions.microsoft.com> wrote in message
news:9F**********************************@microsof t.com...
> Hello !
>
> I want to know if there are an easy way to put a SearchResultCollection
> (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
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...
5
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...
2
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...
0
by: mg | last post by:
SearchResultCollection resultCollection = LDAPsearcher.FindAll() SearchResult resultArray resultArray = new SearchResult resultCollection.CopyTo(resultArray,0) resultCollection.Count is But...
0
by: mg | last post by:
SearchResultCollection resultCollection = LDAPsearcher.FindAll(); SearchResult resultArray; resultArray = new SearchResult; resultCollection.CopyTo(resultArray,0); resultCollection.Count is N ...
3
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...
22
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...
0
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'"....
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.