Solved

Connecting to a Directory Service via LDAP using Lotus Script

Posted on 2008-06-12
9
2,485 Views
Last Modified: 2013-12-18
I'm having real difficult getting a piece of code in VBScript to work properly in Lotus Notes via Lotus Script.  When I do the debug, all is fine until a line which uses GetObject, after which it gives a type mismatch error.  I've since found out that two parameters are required for GetObject in Lotus Script GetObject(Path, Class) whereas the script works perfectly well in VB Script.

Please can somebody let me know which modifications I need to make to get this code working in Lotus Notes
Set ADOConn = CreateObject("ADODB.Connection")

ADOConn.Provider = "ADsDSOObject"

ADOConn.Open "ADs Provider"

		

Set ADOCommand = CreateObject("ADODB.Command")

		

Set ADOCommand.ActiveConnection = ADOConn

		

ADOCommand.CommandText = "<LDAP://uk-bre-cts-vsed-read1.acme.com/dc=acme,dc=com>;(&(objectclass=acmeperson)(uid=bloggs01));adspath;Subtree"

		

Set RS = ADOCommand.Execute

		

If Not rs.eof Then

		

  While Not RS.EOF

		

    Set objUser = GetObject("", RS.Fields("adspath"))

		

    wscript.echo "BU_Cat,"& objuser.get("businesscategory")

    wscript.echo "Country short,"& objuser.get("c")

    wscript.echo "Surname, Forename,"& objuser.get("cn")

    wscript.echo "Country full,"& objuser.get("co")

		

    RS.MoveNext

  Wend

		

End If

		

RS.Close

Set ADOConn = Nothing

Set ADOCommand = Nothing

Set RS = Nothing

Open in new window

0
Comment
Question by:alvshill24
  • 4
  • 3
9 Comments
 
LVL 7

Expert Comment

by:olaraak
ID: 21767481
Sorry about misunderstanding, but where and how you run this script?

If you try to run it as LotusScript, there are differences indeed.

For example, LotusScript does not support identifying arguments for OLE methods or properties by name rather than by the order in which they appear. So, maybe you need to reference GetObject("", RS.Fields("adspath")) by index instead of name.

To clarify what's causing the error, include error trapping:
on error goto errorhandler before other code,
Print  Str(Err) & " " & Error$ & " on row " & Cstr(Erl) in errorhandler:
0
 

Author Comment

by:alvshill24
ID: 21767589
Hi olaraak

The script is run in the PostOpen event of a form.  I identified the issue by turning on LotusScript debugging and stepping through the script using 'Step Into'.  I'll put the error handler in though and feed back it's results.

By the way, the set objuser line (from  the VB Script I adapted the LotusScript code from) was originally: -

Set objUser = GetObject(RS.Fields("adspath"))

In the code I post on this forum, I realised that I'd left in the version that I experimented with, where I used a blank parameter in the hope that is would give Notes what it needed.
0
 

Author Comment

by:alvshill24
ID: 21767739
Ok I get

"Error 13 Type mismatch" corresponding to this line: -
Set objUser = GetObject(RS.Fields("adspath"))

and then

"Error 213 ADODB.Recordset: Item cannot be found in the collection corresponding to the requested name or ordinal." corresponding to this line: -

wscript.echo "BU_Cat,"& objuser.get("businesscategory")

I must apologise as in the Lotus Script i'm actually using the Msgbox command like below.  I had the wscript.echo command lines commented out (as they were directly from the VBScript code).  I was going to convert them for use once I'd managed to successfully retrieve a single value.  Please ignore the wscript lines and regard the line below as I post I'd posted in the code.

Msgbox "NotesDn,"& rs.fields("gsknotesdn").Value
0
 
LVL 7

Expert Comment

by:olaraak
ID: 21767819
Try to reference parameters by index instead of parameter name.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:alvshill24
ID: 21767853
I have no idea what the index name should be, or how this particular command (GetObject) should be formatted to work properly in Lotusscript hence my problem.  Any idea as to how I could find out?

Fyi: I first learned of the differences between Lotusscript and VBScript regard GetObject here: -
http://notes.utk.edu/help/help6_designer.nsf/b3266a3c17f9bb7085256b870069c0a9/17b6311e203650bf85256c1c003fbb5a?OpenDocument
0
 
LVL 7

Expert Comment

by:olaraak
ID: 21768062
You should somehow get the sequence numbers of parameters.
Maybe in Visual Basic, loop through parameters and get their names together with index number 0...N

Set objUser = GetObject("", RS.Fields(0)) ' Replace 0 with actual number of parameter "adspath"

At first you just try with index number 0 to see if the error goes away.
0
 

Author Comment

by:alvshill24
ID: 21972546
Thanks for your help.  I don't think this can be done via LotusScript.  I've since found out about some Java agents that are are being successfully used in my company and will use these instead.
0
 

Accepted Solution

by:
ee_auto earned 0 total points
ID: 23268970
Question PAQ'd, 125 points refunded, and stored in the solution database.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now