jan
(Getting the hang of it)
2004-12-01 03:38 PM
HowTo get LDAP object

Hi,

I've made a script where I want to get info from a LDAP server (NOT AD!). I have no proplems on getting normal LDAP objects as CN, SN, NAME etc. But When I want to get objects we have added to the LDAP I get an error:
COM exception error "get" (Active Directory - The Active Directory datatype cannot be converted to/from a native DS datatype) [-2147352567/80020009]

Hope someone can help me


jan
(Getting the hang of it)
2004-12-01 03:49 PM
Re: HowTo get LDAP object

Btw. I'm using kix 4.22

The code is like this:

BREAK On
$FileName="C:\TEMP\RanaUserInfo.txt"
;$FileName="C:\TEMP\ADUserInfo.txt"
;$LDAP="LDAP://ou=users,ou=kpdk,dc=q8int,dc=com"
$LDAP="cn=HK,cn=Q8"
$predom="LDAP://rana/"
$domain="cn=HK,cn=Q8"


GetAllADUserInfoToFile($domain)



FUNCTION GetAllADUserInfoToFile($dom)
DIM $type
IF EXIST($Filename) = 1
DEL($Filename)
ENDIF
$ou = GETOBJECT($predom+$dom)
FOR EACH $Item IN $ou
$domain=$item.name+","+$dom
$ClassDom=GETOBJECT($predom+$domain)
$kurt=$ClassDom.objectclass
$type=0
FOR EACH $i IN $kurt
SELECT
CASE $i="applicationprocess"
$type=1
CASE $i="q8ansathk"
$type=2
ENDSELECT
NEXT
IF $type = 1
CALL GetAllADUserInfoToFile($domain)
ENDIF
IF $type = 2
IF OPEN(1,"$FileName", 5)= 0
$InitialObj=GETOBJECT($predom+$domain)
$init=$InitialObj.get("initialer")
$out = WRITELINE(1, $init+@serror+@crlf)
$x = CLOSE(1)
ENDIF
ENDIF
NEXT

ENDFUNCTION




Kdyer
(KiX Supporter)
2004-12-01 03:51 PM
Re: HowTo get LDAP object

Well..

This will never work.

;$LDAP="LDAP://ou=users,ou=kpdk,dc=q8int,dc=com"

Is rana a DC? If so, you need entries for your dc too.

Like - dc=rana,dc=q8int,dc=com on the end of your LDAP String.


You need to uncomment this line.

Kent


LonkeroAdministrator
(KiX Master Guru)
2004-12-01 03:56 PM
Re: HowTo get LDAP object

not true.

Kdyer
(KiX Supporter)
2004-12-01 03:59 PM
Re: HowTo get LDAP object

Jooel,

You are right, you can just specify a DC as part of the LDAP://DC..

Maybe spark up a copy of ADSVW.EXE to see what canonical objects, etc. are.

Kent


jan
(Getting the hang of it)
2004-12-01 04:07 PM
Re: HowTo get LDAP object

I know it wouldn't work, that's why I have comment it out :-) It was just for testing.

The LDAP server is NOT a DC. I'm not communicating whit an AD. It's our own LDAP server


jan
(Getting the hang of it)
2004-12-01 04:09 PM
Re: HowTo get LDAP object

Hi,

It's not a Microsoft server I'm trying to communicate with. It's our own LDAP server (running on Solaris)


LonkeroAdministrator
(KiX Master Guru)
2004-12-01 04:12 PM
Re: HowTo get LDAP object

well, going back looking the error, it says it has problem with datatypes and their conversion...

jan
(Getting the hang of it)
2004-12-01 04:14 PM
Re: HowTo get LDAP object

What does that mean?? The native LDAP object (like CN, SN, NAME etc) does work. It's only when I try to get our own objects I get this error

Richard H.Administrator
(KiX Supporter)
2004-12-01 04:15 PM
Re: HowTo get LDAP object

Perhaps you'd be better off with something like an ODBC LDAP connector.

The implication of the error message is that only native MS LDAP objects are supported via the LDAP: provider.


jan
(Getting the hang of it)
2004-12-01 04:16 PM
Re: HowTo get LDAP object

How do I use ODBC LDAP?

Richard H.Administrator
(KiX Supporter)
2004-12-01 04:26 PM
Re: HowTo get LDAP object

Hmm. To be honest I'm not sure

I assumed that someone would have already provided this functionality, but a quick search has not shown up anything useful.

What is your LDAP server based on? Commonly they have a SQL back-end where the data is actually stored so you can interrogate this directly rather than using LDAP.


jan
(Getting the hang of it)
2004-12-01 04:30 PM
Re: HowTo get LDAP object

The person who know what SQL we are running has left, so I can't answer that question

Thanks for you answer


Richard H.Administrator
(KiX Supporter)
2004-12-01 04:41 PM
Re: HowTo get LDAP object

Ok, this is a link to a posting which describes how to access an OpenLDAP service using VB. This should get you started:
http://www.dragoninc.on.ca/mail-archives/openldap-software/2002-04/0484.html


jan
(Getting the hang of it)
2004-12-01 04:46 PM
Re: HowTo get LDAP object

Uuuh I'm not a VB man

Maybe I can find someone who is

Thanks for your help


jan
(Getting the hang of it)
2004-12-01 04:47 PM
Re: HowTo get LDAP object

Does anyone know what else to do?

Richard H.Administrator
(KiX Supporter)
2004-12-01 04:53 PM
Re: HowTo get LDAP object

You should be able to convert it to KiXtart almost word for word.

The best solution however would still be to talk to the back-end database directly.

What else do you know about the LDAP server software?


jan
(Getting the hang of it)
2004-12-01 04:55 PM
Re: HowTo get LDAP object

OK. I'll have a go.

I don't know much about the LDAP server, only it's a LDAP server and it's running on a Sun server


Richard H.Administrator
(KiX Supporter)
2004-12-01 05:08 PM
Re: HowTo get LDAP object

Here is a littoral translation of the sample code into KiXtart, however I don't have anything to test on here:

Code:
; Build the LDAP search condition...
$vSearch = "(sn=Leeds)"

; Instantiate the connection and log in to OpenLDAP
$oConn=CreateObject("ADODB.Connection")
$oConn.Provider = "ADsDSOObject"
$oConn.Open("ADs Provider", "cn=mail_verify,ou=accounts,dc=mckee,dc=com", "mypassword")

; Execute the search...
$oRS=$oConn.Execute("<LDAP://leconte/dc=com/dc=mckee>;" + $vSearch + ";cn,mail")
; Create an array of returned values
$vCount = 1
While Not $oRS.EOF
For Each $vValue in $oRS.Fields(0).value
"Got: "+$vValue ?
Next

$oRS.MoveNext
Loop
Exit 0



jan
(Getting the hang of it)
2004-12-02 10:29 AM
Re: HowTo get LDAP object

Hi,

Got the new search working fine with standard LDAP objects, but when I tried our own defined objects I get this error:
COM exception error "Execute" (Provider - Unspecified error) [-2147352567/80020009]

Jan


Richard H.Administrator
(KiX Supporter)
2004-12-02 11:35 AM
Re: HowTo get LDAP object

Sorry, this is about as far as I can go as I don't have a test environment.

The only things I can think of are:
  • Maybe the LDAP server is throwing an error - have you tried querying using the LDAP servers native client tools to make sure that the search works? Are there any log files associated with the LDAP server that you can check?
  • Maybe the data type you have used simply doesn't work with the MS providers? Have you used the same data types as on the standard objects?


jan
(Getting the hang of it)
2004-12-02 12:16 PM
Re: HowTo get LDAP object

I have no problems with MS clients. I'm using JXplorer and that works finde.

The only thing i do is change the objectname of what I want to display. I'm been told the type is the same for all objects


Richard H.Administrator
(KiX Supporter)
2004-12-02 04:09 PM
Re: HowTo get LDAP object

Ok, there is some good and bad news.

Lots of other people seem to have this problem. I don't really understand LDAP myself, but from what I'm reading the MS LDAP provider caches the LDAP structure locally and uses this to interrogate the server.

Here is a posting I found on a Novell site to fix a similar problem, it is a work-around (highlight in bold are mine):
Quote:

Hi,

Microsoft's ADSI libraries have an incompatibility with the eDirectory
schema
(to which they have been made aware by Novell).

For standard schema entries, your get method will work ok. But for any schema definitions outside the standard set, you will have to tell ADSI what type it is, and read it with the GetInfoEx Arry etc.

For more information on this please go to developer.novell.com/support
and
search on ADSI. For your script, I've pasted a quick sample below.
The types
are enumerated at
http://msdn.microsoft.com/library/en-us/netdir/adsi/adstypeenum.asp?frame=true

Code:

set UserObj=GetObject( "LDAP://myserver/o=novell/cn=admin" )
UserObj.GetInfoEx Array("fullname"), 3
Set entry = UserObj.GetPropertyItem( "fullname", 3 ) 'ci string type
For Each v In entry.Values 'if multivalued attribute
Set propVal = v
descString = propVal.GetObjectProperty(3) 'ci string type
wscript.stdout.writeline descString
Next



Let me know if you have problems with this. It works for me, but I'm
not a
winscript expert by any means.

Thank you
Susan Perrin





Here is a link to a KB article about accessing third-party LDAP servers using ADSI:
http://support.microsoft.com/kb/q251195/

I found these by GOOGLEing using the original error message that you had.