I would like to create a LotusScript "script" which would add a specified database to a users workspace. What is the best way to create and , especially, distribute such a script to the users? The users have Microsoft Outlook email and do not use Lotus Notes mail.
You can just call an URL like Notes://Server/Path/Database.nsf from an email you can send to your users.
You can find more details about URL syntax here
In your answer you have two questions: create script and distribute it.
0. LotusScript for adding database icons
You can use NotesUIWorkspace.AddDatabase method to add database icons to a users workspace:
Dim ws As New NotesUIWorkspace
'...
ws.AddDatabase("Your DB0 Server", "Your DB0 FilePath")
ws.AddDatabase("Your DB1 Server", "Your DB1 FilePath")
ws.AddDatabase("Your DB2 Server", "Your DB2 FilePath")
'...
1. Distribution of any script
You can send the Notes URL to users which would run your script. For this you need to create a Form which run your script in the PostOpen event:
Sub Postopen(Source As Notesuidocument)
Dim ws As New NotesUIWorkspace
'Your script here
Call ws.CurrentDocument.Close
End Sub
So, is better to create profile document with such a form and send URL of this document to users:
Dim ses As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim mdoc As NotesDocument
Dim body As NotesMIMEEntity
Dim stream As NotesStream
Dim nname As NotesName
Set db = ses.CurrentDatabase
Set doc = db.GetProfileDocument("YourProfileDocument")
ses.ConvertMIME = False
Set mdoc = db.CreateDocument
mdoc.SendTo = "Your_users_mail#domain.foo"
mdoc.Subject = "Take a look"
Set stream = ses.CreateStream
Set body = mdoc.CreateMIMEEntity
Set nname = ses.CreateName(db.Server)
Call stream.WriteText({Please open this link.})
Call body.SetContentFromText(stream, "text/html;charset=utf-8", ENC_IDENTITY_8BIT)
Call mdoc.Send(False)
In other hand if you want just to add some databases without any computations then you don't need such a script. As suggested by Knut Herrmann:
You could just call an URL like Notes://Server/Path/Database.nsf.
But beware, it does not add database icons to workspace in earlier versions of Lotus Notes (7 or earlier).
Related
I'm trying to write a VB script that will log into a secure website and download a series of reports.
The following gets me into the website, but after login the whole site is written in javascript.
Dim oIE
Set oIE = CreateObject("InternetExplorer.Application")
With oIE
.Visible = True
.Navigate SecureWebsite
Do While .Busy Or Not .readyState = 4: WScript.Sleep 100: Loop
Do Until .document.readyState = "complete": WScript.Sleep 100: Loop
Do While TypeName(.document.getElementById("username")) = "Null": WScript.Sleep 100: Loop
End With
Set Helem = oIE.document.getElementByID("username")
Helem.Value = "myusername"
Set Helem = oIE.document.getElementByID("password")
Helem.Value = "mypassword"
Call oIE.Document.all.loginForm.submit
I've found a link that I can use with parameters to search for the reports I need. When I follow the link, Internet Explorer returns a JSON file that I can open/download. The JSON file contains a Report ID that I can use as a parameter in another link to download the file that I need.
Is there any way using the InternetExplorer object to read the text contents of the JSON file into a variable so that I can parse the Report ID out of it? All the examples I've found use the MSXML2.XMLHTTP object, but that disconnects it from the sign-on I've achieved in the InternetExplorer object.
I ended up doing this in C#. The website had redirects and SSO so I couldn't get a direct WebClient Get/Post, but I compromised by logging in using a WebBrowser object and then passing the cookies to a HttpWebRequest object, per this excellent guide:
https://www.codeproject.com/Tips/659004/Download-of-file-with-open-save-dialog-box
I am trying to use the WinSCP COM library on a old VB6 project I have (it's a legacy application that generates an OCX file, I think we have to use VB6 for it but not 100% sure).
Anyway we want to implement SFTP, and WinSCP can do that readily.
I registered the COM object, and can see the WinSCPNet type library when I go to add the reference. However I can't see the properties/methods of the classes when I look at the library in the object browser. Further, this code fails, it does not get to the 3rd MsgBox ("In SendWinSCP4"), it returns from the function at that point, I think because the property UserName is not exposed.
MsgBox ("in SendWinSCP")
Dim session As WinSCPnet.session
Dim sessionOptions As WinSCPnet.sessionOptions
Dim transferOptions As WinSCPnet.transferOptions
Set session = New WinSCPnet.session
Set sessionOptions = New WinSCPnet.sessionOptions
Set transferOptions = New WinSCPnet.transferOptions
MsgBox ("in SendWinSCP3")
sessionOptions.Protocol = Protocol_Sftp
sessionOptions.HostName = "example.com"
sessionOptions.UserName = "user"
sessionOptions.Password = "example.com"
sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
MsgBox ("in SendWinSCP4 " & sessionOptions.HostName & "!")
See above, using On Error Resume Next got me past the error.
I am trying to list QC11 project and domain name in combo box on form load() but I am getting error object required,code I am using:
Dim tdc As New TDAPIOLELib.TDConnection
Dim projectList As Customization
Dim Project As Customization
Dim Domain As Customization
Set tdc = CreateObject("TDApiOle80.TDConnection")
tdc.InitConnectionEx "https://xyz/omu"
For Each Domain In TheTDConnection.DomainsList
Set projectList = tdc.GetAllVisibleProjectDescriptors
For Each Project In projectList
ComboBox1.AddItem (Project.Name)
ComboBox2.AddItem (Project.DomainName)
Next Project
Next Domain
If that's really the code you are using, then for a start this line is probably generating an error:
For Each Domain In TheTDConnection.DomainsList
Based on the rest of your code "TheTDConnection" should be "tdc":
For Each Domain In tdc.DomainsList
Oh, and to be doing this you should almost certainly be logged in first by calling tdc.Login... rather than just connected to the server.
On a related note, the DomainsList property is deprecated. I think you can just loop through the List of ProjectDescriptor objects returned by GetAllVisibleProjectDescriptors since that covers all projects under all domains that the current logged on user has access to.
Edit: this is a complete solution based on the original question. Here's working tested code that will cycle through the domains/projects that the provided user has access to. This assumes you have the QC/ALM Connectivity add-in installed (required).
If you are running this piece of VBScript on a 64 bit machine you need to run it using the 32bit version of wscript.exe: C:\Windows\SysWOW64\wscript.exe "c:\somewhere\myscript.vbs"
msgbox "Creating connection object"
Dim tdc
Set tdc = CreateObject("TDApiOle80.TDConnection")
msgbox "Connecting to QC/ALM"
tdc.InitConnectionEx "http://<yourServer>/qcbin/"
msgbox "Logging in"
tdc.Login "<username>", "<password>"
Dim projDesc
msgbox "Getting project descriptors"
Set projectDescriptors = tdc.GetAllVisibleProjectDescriptors
For Each desc In projectDescriptors
msgbox desc.DomainName & "\" & desc.Name
Next
msgbox "Logging out"
tdc.Logout
msgbox "Disconnecting"
tdc.Disconnect
msgbox "Releasing connection"
tdc.ReleaseConnection
Edit 2:
If you want to parse the resulting XML from sa.GetAllDomains into a list of ALL domain\project items on the server you can do this (This is VBScript since the original question & tag still mention it, and has been tested):
Set objDoc = CreateObject("MSXML.DOMDocument")
objDoc.Load "C:\yourXmlFile.xml"
Set objRoot = objDoc.documentElement
For Each domain in objRoot.selectNodes("TDXItem")
For Each project in domain.selectNodes("PROJECTS_LIST/TDXItem")
msgbox domain.selectSingleNode("DOMAIN_NAME").text & "\" & project.selectSingleNode("PROJECT_NAME").text
Next
Next
I am trying to obtain meta data based on a users selection. I am using the ADODB namespace to provide a connection to the database and a recordset to retrieve data from it. I have set up a connection and tested it, this works fine, but the retrieval of the data is not working.
Here is the main segment:
con.Open()
cat.ActiveConnection = con
Select Case chk.Tag
Case "Yes"
For Each modMainFunctions.tbl In cat.Tables
If tbl.Type = "TABLE" Then
frmMain.lstTables.Items.Add(tbl.Name)
End If
Next
End Select
Essentially, I am checking if a particular checkbox has been selected, if it is has "i.e. case "yes" then I am trying to retrieve the Database TABLES from the provided database. However, the compiler doesn't reach the FOR loop and I cannot understand why...
modMainfunctions is my module with the main functions of my program are stored, within it I declare all my necessary variables:
Dim dbname As String = ""
Dim dblocation As String = Application.StartupPath
Dim con As New ADODB.Connection
Dim cat As New ADOX.Catalog
Dim tbl As New ADOX.Table
Dim col As ADOX.Column
Dim view As ADOX.View
Dim key As ADOX.Key
Dim index As New ADOX.Index
Can anyone see where I am going wrong? I want to obtain the meta data about a database (Please do not answer with "you need to connect to..." etc because I have already a subroutine which deals with this and it's working fine, I don't think it is a connection issue)
Problem solved, rather than storing this procedure in a module I simply stored it in the active form, I am unsure if this is the "best practise" but so long as my code is working as expected I'm happy. I realised that the error was because I didn't spell the world "yes" correctly... It was looking for the word "yes" and I typed "Yes" clearly the significance of thoroughly reading your code can be learnt here!
I am trying to get a user's SIP address so I can use a JavaScript object to check their presence in Office Communicator. Here is a script I found that is similar to what I am looking to do.
Option Explicit
DIM objConnection, objCommand
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
Dim objOU, objUser, strUPN, strSIP, SIPLine
' Bind to the OU object.
Set objOU = GetObject("LDAP://chkenergy.net/DC=chkenergy,DC=net")
' Enumerate all users in the OU.
objOU.Filter = Array("user")
For Each objUser In objOU
' Skip computer objects.
If (objUser.Class = "user") Then
strUPN = objUser.userPrincipalName
strSIP = objUser.get("msRTCSIP-PrimaryUserAddress")
wscript.echo strSIP
End If
Next
Basically, I can get their username from AD, and I would like to pass that in and get their SIP address (strSIP) back. Is there a way to fix this code to do that task specifically?
The problems of your posted vbscript are
It enumerates the user on the client side, which will take a lot of time to find the correct user. Similarly, instead of pulling all the records from the database and do the comparison on your client side, you would run a SQL query. Right?
The enumeration is done at one single level only. You have to fix your code to do recursive enumeration. However, if you fix it to do recursive enumeration, it's going to take even longer time and even more resources to do your job.
Before I answer your question, here are some basic background knowlege on Active Directory.
User objects on Active Directory contains a number of attributes.
In particular, samAccountName is your pre-Windows 2000 name.
userPrincipalName is in the format of user#domain.name
You can actully execute a query using an ADO connection object. Since you are binded to an Active Directory, you can execute a LDAP query. The LDAP query string contains four parts.
Root path, where we start the search.
LDAP filter
Returned attributes
Search scope
The LDAP query string that you should use should be something like
<LDAP://chkenergy.net/DC=chkenergy,DC=net>;(&(objectClass=user)(samAccountName=yourusername));msRTCSIP-PrimaryUserAddress;subtree
The root path in the above example is <LDAP://chkenergy.net/DC=chkenergy,DC=net>.
The LDAP filter is (&(objectClass=user)(samAccountName=yourusername)). Of course, you need to replace yourusername to something else inside your code. I am assuming you can pass in a samAccountName. If that's not the case, you need to modify the filter yourself.
Returned attributes is msRTCSIP-PrimaryUserAddress. I think that's what you need. Right?
I am assuming you are trying to search for all user objects under the same domain. So, your search scope should be subtree
Here is a complete sample that I guess it should do your job
userName = "harvey"
ldapStr = "<LDAP://chkenergy.net/DC=chkenergy,DC=net>;(&(objectClass=user)(samAccountName=" & userName & "));msRTCSIP-PrimaryUserAddress;subtree"
Set conn = CreateObject("ADODB.Connection")
conn.Provider = "ADSDSOObject"
conn.Open "ADs Provider"
Set rs = conn.Execute(ldapStr)
While Not rs.EOF
wscript.echo rs.Fields("msRTCSIP-PrimaryUserAddress")
rs.MoveNext
Wend