Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

plz Help! Error: The AD datatype cannot be converted

161 views
Skip to first unread message

lbb

unread,
Jun 5, 2002, 5:26:10 AM6/5/02
to
I´m reading user attributes from AD onto an ASP page. When
I read certain attributes I get either an unspecified
error or the error message here below, depending on what
code I use. There seem to be alot of people struggling
with this error, I would really appreciate it if someone
would take the time to look at it.

The error message:
Active Directory (0x8000500C)
The Active Directory datatype cannot be converted to/from
a native DS datatype

I´ve tried the suggestions on the
http://support.microsoft.com/default.aspx?scid=kb;en-
us;Q241981 page but it didn't work.

I´ve also tried updating the cache like suggested here in
reply to Samba on the 18th. of April 2002. (same problem)
It too didn´t work.

I´ve looked at the schema definitions for department and
title and they are exactly the same although I can query
title but not department.

-----------------------------------------------------------
-------------------------------------------------------
Here´s my code:

strADsPath = LDAP://DC=xyz,DC=is
strBase = "<" & strADsPath & ">"

Set adoConnection = Server.CreateObject
("ADODB.Connection")
adoConnection.Open "Provider= ADsDSOObject"
Set adoCommand = Server.CreateObject("ADODB.Command")
Set adoCommand.ActiveConnection = adoConnection

strObjects = "(objectClass='user')"
strFilter = "(" & strObjects & ")"
strAttributes = "cn,department,title"
strScope = "subTree"
adoCommand.CommandText = strBase & ";" & strFilter & ";" &
strAttributes & ";" & strScope
adoCommand.Properties("Sort On") = "cn"

'****The execution fails if I have the department
attribute specified in strAttributes, If I don´t
everything works perfectly.
Set adoRS = adoCommand.Execute

-----------------------------------------------------------
-----------------------------------------------------------
---

Thanks in advance,
Linda

Stephen Travis

unread,
Jun 6, 2002, 11:12:40 AM6/6/02
to
Sorry to but-in on your thread but I've reached the end of my patience with this issue. I have the same problem using ASP and I also
tried doing the same thing in ASP.Net and it returned this error;

System.NotImplementedException: Handling of this ADSVALUE type is not yet implemented (type = 0xb).

on department and company.

The odd thing is that the same exact VBscript works perfectly as a .vbs program.

This together with the fact that there are multiple ways of doing the same thing and multiple ways of referring to the same object,
each of which seems to have their own idiosyncrasies/bugs, I'm about to dump ADSI.

"lbb" <lindabja...@hotmail.com> wrote in message news:a63201c20c73$0780d050$36ef2ecf@tkmsftngxa12...
I惴 reading user attributes from AD onto an ASP page. When


I read certain attributes I get either an unspecified
error or the error message here below, depending on what
code I use. There seem to be alot of people struggling
with this error, I would really appreciate it if someone
would take the time to look at it.

The error message:
Active Directory (0x8000500C)
The Active Directory datatype cannot be converted to/from
a native DS datatype

I扉e tried the suggestions on the

I扉e also tried updating the cache like suggested here in


reply to Samba on the 18th. of April 2002. (same problem)

It too didn愒 work.

I扉e looked at the schema definitions for department and


title and they are exactly the same although I can query
title but not department.

-----------------------------------------------------------
-------------------------------------------------------
Here愀 my code:

strADsPath = LDAP://DC=xyz,DC=is
strBase = "<" & strADsPath & ">"

Set adoConnection = Server.CreateObject
("ADODB.Connection")
adoConnection.Open "Provider= ADsDSOObject"
Set adoCommand = Server.CreateObject("ADODB.Command")
Set adoCommand.ActiveConnection = adoConnection

strObjects = "(objectClass='user')"
strFilter = "(" & strObjects & ")"
strAttributes = "cn,department,title"
strScope = "subTree"
adoCommand.CommandText = strBase & ";" & strFilter & ";" &
strAttributes & ";" & strScope
adoCommand.Properties("Sort On") = "cn"

'****The execution fails if I have the department

attribute specified in strAttributes, If I don愒

Bruno Lopes

unread,
Jun 6, 2002, 12:11:14 PM6/6/02
to
I have the same ADSVALUE problem with a C# program that acesses a ldap
directory.
Could you please elaborate on how which ways do return the correct values?
I believe that the values get "translated" based on the key name and
when ADSI finds a key he has no way to translate, instead of letting it
be and pass the value as it is it returns that error (something i find,
well, idiotic...).

TIA, Bruno Lopes

Stephen Travis

unread,
Jun 6, 2002, 12:40:14 PM6/6/02
to
Hi Bruno... Here's an ASP.Net page in Vb that works, with the offending items commented out;

NOTE: company and department (which have values) throw the 'NotImplementedException' while employeeID, manager, employeeNumber throw
a NullReferenceException (because they are null)

<%@Assembly Name="System.DirectoryServices, Version=1.0.3300.0,Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"%>
<%@ Page Language="vb" Debug = "True" Trace="False"%>
<%@ Import Namespace="System"%>
<%@ Import Namespace = "System.DirectoryServices"%>
<html>
<head>
<title>ASP.Net</title>
</head>
<body>
<script language="VB" runat="server">
Sub Page_Load (sender As Object, e As EventArgs)
Dim root As New
System.DirectoryServices.DirectoryEntry("LDAP://dep.govt.state.ma.us/DC=dep,DC=govt,DC=state,DC=ma,DC=us","STravis", "JeepTJ#14")
Dim searcher As New System.DirectoryServices.DirectorySearcher(root)
Dim alias1 As String
searcher.Filter = ("sAMAccountName=STravis")

Dim results As SearchResultCollection
results = searcher.FindAll()
Dim result As SearchResult
For Each result In results
'Response.Write(result.Properties("employeeID")(0))
Response.Write(result.Properties("givenName")(0))
Response.Write(result.Properties("sn")(0))
Response.Write(result.Properties("cn")(0))
Response.Write(result.Properties("telephoneNumber")(0))
Response.Write(result.Properties("mail")(0))
Response.Write(result.Properties("description")(0))
Response.Write(result.Properties("title")(0))
Response.Write(result.Properties("physicalDeliveryOfficeName")(0))
'Response.Write(result.Properties("company")(0))
'Response.Write(result.Properties("manager")(0))
Response.Write(result.Properties("department")(0))
'Response.Write(result.Properties("employeeNumber")(0))
Next result
End Sub
</script>
</body>
</html>


"Bruno Lopes" <winte...@aeiou.pt> wrote in message news:3CFF89A2...@aeiou.pt...

Bruno Lopes

unread,
Jun 6, 2002, 12:58:54 PM6/6/02
to
Is that server an AD or LDAP? Are company and department "custom"
atributes or do they come with the server schema?
Currently i'm trying to see if i can get to the values before they are
maimed, but my hopes are low...

Stephen Travis wrote:
> Hi Bruno... Here's an ASP.Net page in Vb that works, with the offending items commented out;
>
> NOTE: company and department (which have values) throw the 'NotImplementedException' while employeeID, manager, employeeNumber throw
> a NullReferenceException (because they are null)
>
<snip>

Stephen Travis

unread,
Jun 6, 2002, 1:11:23 PM6/6/02
to
It's AD accessed via the LDAP provider and I believe that department and company come with the default schema.

--

Stephen Travis,
Microsoft MVP - FrontPage

"Bruno Lopes" <winte...@aeiou.pt> wrote in message news:3CFF94C...@aeiou.pt...

Bruno Lopes

unread,
Jun 6, 2002, 1:16:43 PM6/6/02
to
Well, that makes it even odder.. I thought this feature had something to
do with custom atributes, but now with your problem...
Sorry i couldn't be of any help, but I think this has to be _deep_
inside the ADSI... but then again, if someone finds a miracle cure I'm
sure to be gratefull :)

Stephen Travis

unread,
Jun 6, 2002, 2:41:55 PM6/6/02
to
Come to think of it, I think that's butt-in ;-)

--

Stephen Travis,
Microsoft MVP - FrontPage

"Stephen Travis" <str...@iname.com> wrote in message news:OKtsAyWDCHA.1544@tkmsftngp02...

David Stucki [MS]

unread,
Jun 6, 2002, 6:50:09 PM6/6/02
to
This problem usually occurs when the security isn't (or wasn't) configured
properly. What type of IIS authentication is being used? Anonymous, Basic,
or Integrated Windows? What OS is the web server running? What OS are the
IE Clients running? Are the clients logged on to the domain the webserver
and AD are in?

Dave Stucki
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------

Stephen Travis

unread,
Jun 6, 2002, 8:40:37 PM6/6/02
to
Since we don't manage the AD, I'm not sure how it's set up. We run W2000 clients and servers and I believe the IIS server (a staging
platform) I'm running on is in the same domain as the AD server and the client. The IIS server is set up for anonymous access but
I'm using a Response.AddHeader "WWW-Authenticate","NTLM" to force a login in ASP and am passing the username and password to the
DirectoryEntry in ASP.Net.

Is there field level security is AD that would allow access via a .vbs script but not via ASP? Can I point my admin at a particular
security configuration setting?

--

Stephen Travis
Microsoft MVP - FrontPage

"David Stucki [MS]" <a-d...@online.microsoft.com> wrote in message news:qoozHyaDCHA.1600@cpmsftngxa08...

Bruno Lopes

unread,
Jun 6, 2002, 8:57:33 PM6/6/02
to
On my part i'm trying to connect to an openLDAP server on a linux
machine, using a previlieged (sic?) account on a c# aplication running
on a win2k OS. Does ADSI tries to retrieve the type of the attribute
from the server, being that the problem?

TIA, Bruno Lopes

David Stucki [MS]

unread,
Jun 7, 2002, 4:44:12 PM6/7/02
to
If you're trying to contact an LDAP server that isn't the AD it may be a
schema problem. ADSI/DirectoryServices tries to read the schema
information to know how to handle data returned from an v3 LDAP Server.
Some third-party servers don't do this correctly, sometimes ADSI isn't
expecting schema definitions that don't exist in the AD. Anyway, it looks
like ADSI may not know how to handle the data. You could try to work
around using the IADsProperty* interfaces. Here's a sample with a
Class/Function that you can just call from your code, you shouldn't have to
change any of the code in the PropertyHelper class, just use it in your
code.

using System;
using ActiveDs;
using System.DirectoryServices;

namespace Microsoft.PropertyInterfaces
{
class MainClass
{
[STAThread]
static void Main(string[] args)
{
DirectoryEntry group = new
DirectoryEntry("LDAP://CN=Domain
Admins,CN=Users,DC=dsdom,DC=extest,DC=microsoft,DC=com");
foreach(string member in
PropertyHelper.GetProperty(group,"member", ADSTYPEENUM.ADSTYPE_DN_STRING))
{
Console.WriteLine(member);
}
}
}

class PropertyHelper
{
public static object[] GetProperty(DirectoryEntry entry, string
propertyName, ADSTYPEENUM adsType)
{
//Make sure to get this value from the LDAP directory
entry.RefreshCache(new string[]{propertyName});
//QI for the IADsPropertyList interface from the
underlying IADs
IADsPropertyList propList =
(IADsPropertyList)entry.NativeObject;
//Get this property's IADsPropertyEntry
IADsPropertyEntry propEntry =
(IADsPropertyEntry)propList.GetPropertyItem(propertyName,(int)adsType);

//Use this ArrayList to build the array of return values
System.Collections.ArrayList values = new
System.Collections.ArrayList();

//Loop through each value in the collection
foreach(IADsPropertyValue propValue in
(object[])propEntry.Values)
{
switch(adsType)
{
case ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING:
values.Add(propValue.CaseIgnoreString);
break;
case ADSTYPEENUM.ADSTYPE_CASE_EXACT_STRING:
values.Add(propValue.CaseExactString);
break;
case ADSTYPEENUM.ADSTYPE_DN_STRING:
values.Add(propValue.DNString);
break;
case ADSTYPEENUM.ADSTYPE_INTEGER:
values.Add(propValue.Integer);
break;
case ADSTYPEENUM.ADSTYPE_BOOLEAN:
values.Add(propValue.Boolean);
break;
case ADSTYPEENUM.ADSTYPE_LARGE_INTEGER:
values.Add(propValue.LargeInteger);
break;
case ADSTYPEENUM.ADSTYPE_OCTET_STRING:
values.Add(propValue.OctetString);
break;
default:
throw new
System.NotImplementedException("Handling of this ADSTYPE is not
implemented");
}
}
return values.ToArray();

}
}

}

Hope this helps!

Bruno Lopes

unread,
Jun 7, 2002, 11:30:46 PM6/7/02
to
Worked like a charm :) A really pretty, large, useful, albeit a little
slow charm, since i'm doing it one time for each of the 60 and some
attributes each entry on the LDAP directory contains. Probably I'm going
to build a "global" GetProperties for an entry so to spare the
RefreshCache for each attrib. Other than that I'm an happy coder.

May I suggest to put this sample code somewhere people can find when
searching for "System.NotImplementedException: Handling of this ADSVALUE
type is not yet implemented (type = 0xb)." or "Active Directory (0x8000500C)


The Active Directory datatype cannot be converted to/from

a native DS datatype" ? Or is this more likely to be a problem with the
LDAP server and schemas?
Thanks a whole bunch!

Bruno Lopes

David Stucki [MS] wrote:
> If you're trying to contact an LDAP server that isn't the AD it may be a
> schema problem. ADSI/DirectoryServices tries to read the schema
> information to know how to handle data returned from an v3 LDAP Server.
> Some third-party servers don't do this correctly, sometimes ADSI isn't
> expecting schema definitions that don't exist in the AD. Anyway, it looks
> like ADSI may not know how to handle the data. You could try to work
> around using the IADsProperty* interfaces. Here's a sample with a
> Class/Function that you can just call from your code, you shouldn't have to
> change any of the code in the PropertyHelper class, just use it in your
> code.
>

<SNIP>

0 new messages