Sign in to follow this  
Followers 0
mc1226

VARIANT datatype returned from a COM method

3 posts in this topic

I'm a novice using COM support in AU3 ... so have mercy

I'm using an ActiveX control from Novell Developers Kit supporting LDAP query.

If I use the control with VBScript no problem; when I translate the script in AU3 the method returnig value(s) for an attribute of a searched object give non results.

This is an OLEVIEW export of the method

[id(0x00000004), propget, helpstring("Returns the requested field value"), helpcontext(0x00000026)]

VARIANT FieldValue([in] BSTR FieldName);

I think the problem is the VARIANT datatype.

This is the fully functional VBScript

Option Explicit 
Dim oShell
Dim oNWQry
Dim oNWLst
Dim nOggetti
Dim oNWUsr
Dim aValori
'
Set oShell = WScript.CreateObject("WScript.Shell")
Set oNWQry = WScript.CreateObject("NWIDirQueryLib.NWIDirQuery.1.2")
oNWQry.FullName = "ldap://server/o=myorg/ou=myou1"
oNWQry.Filter   = "(&(objectclass=inetOrgPerson)(|(surname=FO0233*)(uid=FO0233*)(cn=FO0233*)))"
oNWQry.Fields = "sn, givenName"
oNWQry.TimeLimit = 60
oNWQry.SearchScope = 2
oNWQry.MaximumResults = 20
oNWQry.SearchMode = 0
oNWQry.AutoReferral = 1
' LDAP Connect
oNWQry.Connect
' LDAP Search
Set oNWLst = oNWQry.Search
' goto 1st object Item(0)
Set oNWUsr=oNWLst.Item(0)
' show object shortname tipically cn=userid  
oShell.Popup oNWUsr.ShortName
' value(s) for attribute "sn" in array aValori 
aValori = oNWUsr.FieldValue("sn")
' show 1st value for attribute
oShell.Popup aValori(0)
' LDAP Disconnect
oNWQry.DisConnect
WScript.Quit

The Autoit3

$oNWQry = ObjCreate("NWIDirQueryLib.NWIDirQuery.1.2")
$oNWQry.FullName = "ldap://server/o=myorg/ou=myou1"
$oNWQry.Filter = "(&(objectclass=inetOrgPerson)(|(surname=FO0233*)(uid=FO0233*)(cn=FO0233*)))"
$oNWQry.Fields = "sn, givenName"
$oNWQry.TimeLimit = 60
$oNWQry.SearchScope = 2
$oNWQry.MaximumResults = 20
$oNWQry.SearchMode = 0
$oNWQry.AutoReferral = 1
' LDAP Connect
$oNWQry.Connect
' LDAP Search
$oNWLst=$oNWQry.Search
' goto 1st object Item(0)
$oNWUsr=$oNWLst.Item(0)
' show object shortname tipically cn=userid 
Msgbox(0,"",$oNWUsr.ShortName)
$aValori=$oNWUsr.FieldValue("sn")
' aValori is not an array, the variable is null

Do you know if VARIANT datatype is supported for OLE/COM in Autoit3 or there is another error in my vbs->au3 porting.

TIA

Vincenzo

Share this post


Link to post
Share on other sites



Do you know if VARIANT datatype is supported for OLE/COM in Autoit3 or there is another error in my vbs->au3 porting.

TIA

Vincenzo

Small correction. You are using VBS comment markers ' instead of AutoIt comment markers ;.

Share this post


Link to post
Share on other sites

Small correction. You are using VBS comment markers ' instead of AutoIt comment markers ;.

Sorry, in post I didn't use original Autoit source but modified from VBS (and non correctly .... as you can see). The original source is bigger and with confidential data...

I confirm the error/behaviour: variable $aValori is non an array as in VBS, but an empty variable.

If LDAP attribute is multivalue in VBS you obtain an array cointaining every value, for a monovalue attribute the array has only one element.

Thanks for your correction.

Vincenzo

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0