473,386 Members | 1,819 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,386 software developers and data experts.

The Active Directory datatype cannot be converted to/from a native DS datatype

I am trying to retrieve the users of the company using active directory.

When i execute the code below , it gives the following error

"The Active Directory datatype cannot be converted to/from a native DS
datatype"

could anyone help me with this please. i already passed two days trying to
figure out what is the problem.

thank you very much

the code is in J#

/**************************************************/

private System.DirectoryServices.DirectoryEntry root;

private System.DirectoryServices.DirectorySearcher ds;

private System.DirectoryServices.SearchResultCollection src;

private System.DirectoryServices.SearchResult result;

private System.DirectoryServices.DirectoryEntry user;

root = new
System.DirectoryServices.DirectoryEntry(LDAP_ROOT, LDAP_NAME,LDAP_PASS);

ds = new System.DirectoryServices.DirectorySearcher(root);

ds.set_CacheResults(true);

ds.set_Filter("(&(objectCategory=Person)(objectCla ss=user))");

src = ds.FindAll();

for(int i=0 ;i<totalRows ;i++)

{
result = (System.DirectoryServices.SearchResult) src.get_Item(i);

user = result.GetDirectoryEntry();

if(user != null)

{

user.get_Properties().get_Item("givenName").get_Va lue().ToString();

}

}



Nov 22 '05 #1
1 4603
>I am trying to retrieve the users of the company using active directory.
When i execute the code below , it gives the following error

"The Active Directory datatype cannot be converted to/from a native DS
datatype"

could anyone help me with this please. i already passed two days trying to
figure out what is the problem.


Well, if you do a search using DirectorySearcher, you should specify
which attributes you're interested in, so that those will be retrieved
for each of your resulting objects. This saves you from having to go
back to the full DirectoryEntry for each search result (saving you at
least one network roundtrip).

This is in C# - should be easy enough to translate into J#:

DirectorySearcher ds = new DirectorySearcher(root);
ds.Filter = "(&(objectCategory=Person)(objectClass=user))" ;

ds.PropertiesToLoad.Add("givenName");
// add any other properties you're interested in!

foreach(SearchResult oRes in ds.FindAll() )
{
Console.WriteLine(oRes.Properties["givenName"].Value);
}

Marc
================================================== ==============
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
Nov 22 '05 #2

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

Similar topics

2
by: Jay Chan | last post by:
We have just installed a SQL Server 2000 (SP 3A) onto a computer that has Windows-2003 Server on it. Now, we cannot get access to that database server from other computers. Seem like this may be an...
1
by: Hechmi | last post by:
I am trying to retrieve the users of the company using active directory. When i execute the code below , it gives the following error "The Active Directory datatype cannot be converted to/from...
0
by: Jeremy Chapman | last post by:
I built a page to view user ActiveDirectory object properties. On my machine it works well, however when I moved the page to a different machine I get exceptions being thrown when trying to view...
1
by: Robin | last post by:
When using the following ASP.Net code the error "The directory service cannot perform the requested operation on the RDN attribute of an object." is displayed when the commit changes is run. What...
2
by: Johan Delimon | last post by:
"The active directory datatype cannot be converted to/from a native DS datatype" I have an ASP.NET web page that uses queries to AD to identify current users. Delegation is configured in AD and...
0
by: Ciccio | last post by:
Hi I'm new to active directory programming. From an asp.net application that uses AD I got an excepion of type: System.Runtime.InteropServices­.COMException (0x8000500C): The Active Directory...
6
by: varkey.mathew | last post by:
Dear all, Bear with me, a poor newbie(atleast in AD).. I have to authenticate a user ID and password for a user as a valid Active Directory user or not. I have created the IsAuthenticated...
10
by: Hriday | last post by:
Hi there, Please help me..It is urgent This is Hriday, working on windows authentication with Active Directory... My requirment is when a user sends a request to my web Applicatoin I want to...
2
by: P Webster | last post by:
We recently moved a web site that validated user credentials in Active Directory from IIS 5.1 to IIS 6, and the validation code no longer works. The web.config file is set to Windows authentication...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
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.