notes url (notes://) sometimes does not create icon on workspace - lotus-notes

I'm maintaining an application which sends out E-Mails with a notes url link like this:
noteshref = "notes://" & serverName.Common & "/" & docToLink.Parentdatabase.Replicaid & "/" & viewUNID & "/" & docToLink.Universalid
the viewUNID is calculated thusly:
Dim viewUNID As String
Set nc = db.Createnotecollection(False)
nc.Selectviews=True
nc.Selectionformula={#isMember("Vtousdocuments";#explode($Title;"|"))}
nc.Buildcollection
If nc.Count > 0 Then
viewID = nc.Getfirstnoteid
Dim note As NotesDocument
Set note = db.Getdocumentbyid(viewID)
viewUNID=note.Universalid
Delete note
Else
viewUNID="0"
End If
Delete nc
I've looked at the documentation for the NotesURL:
https://www-10.lotus.com/ldd/dominowiki.nsf/dx/notes-urls
I've seen demonstrations via a remote session when the database icon on the workspace is not created when opening the link. The Document gets opened, but no bananas on the 'create a Workspace icon on the database' behaviour.
I haven't been able to reproduce this on my machine, and I've also noted that, contrary to the documentation, the server 'hint' is not considered - one of the possible replicas is pulled out of thin air and recreated on the workspace.
Am I missing anything? Are there perhaps some combinations of the notesurl that do not create icons on the workspace (i.e. a naming convention for the server)? Or could it be something more obscure, like corrupted desktop.ndks?

I have used this URL format in few places and it has always worked and it opens the right server. One thing I do differently is use /0/ instead of the view UNID "/" & viewUNID & "/". This would directly open the document if its present in the db and its also faster.
But your solution also should work, if the issue is specific for few users you should delete the cache/desktop and try.

Related

Lotus script to move mass domino users mail databases from csv file

I need a lotus script for mass move of users mail files from one domino directory to another. I've found script for mass user deletion and just replaced method notesAdministrationProcess.DeleteUser with method noteID$ = notesAdministrationProcess .MoveMailUser( username$ , newhomeserver$ , newhomeservermailpath$ ) , where is newhomeservermailpath$ - moved - directory which I previously created to move mail files from default mail folder mail. Domino console didn't report any error but script doesn't move user's mail files. What is missing? Am I doing something wrong?
Script code:
Sub Initialize
Dim session As New NotesSession
Dim db,addbk As NotesDatabase
Dim usrvw As NotesView
Dim Username As String
Dim movecounter As Integer
Dim nap As NotesAdministrationProcess
Dim FIleNumber As Integer
Dim Filename As String
Set nap = session.CreateAdministrationProcess("MyServer/myserverdomain")
Set db = session.CurrentDatabase
Set addbk=session.GetDatabase("MyServer/myserverdomain","names.nsf",0)
Set usrvw=addbk.getview("$NamesFieldLookup")
filenumber%=FreeFile()
fileName$="D:\moveMail.csv"
Open fileName For Input As fileNumber%
On Error Resume Next
movecounter=0
Do Until EOF(fileNumber%)
Input #fileNumber%,Username
movecounter=movecounter+1
Call nap.MoveMailUser(Username, MyServer/myserverdomain , moved)
Print "Moved" & CStr(movecounter) "Users"
Loop
End Sub
There are -as stated in comments- some major problems with your code:
First: NEVER use "On Error Resume Next" except for expected single errors you want to suppress.
Your case is the best example: Your code fails because of non defined variables, but you will never get an error message because you suppress it: No chance of knowing where it went wrong.
Second: EVER add
Option Declare
to any code you write in LotusScript. There is even a Designer setting to do this automatically. This option would have checked if all variables you use are declared... and would have not even allowed you to save this code.
Third: The errors in code. You managed to produce 2 errors when changing one single line of code...
This is how it looks:
Call nap.MoveMailUser(Username, MyServer/myserverdomain , moved)
This is how it should look:
Call nap.MoveMailUser(Username, "MyServer/myserverdomain" , "moved")
Just look at the difference... I will not start to teach you basics about variables vs. string literals as these are the same for almost every programming language.
-off topic-
One more thing: The way you approach business tasks is reckless at least but in any case very dangerous... You seem to copy some code from somewhere but even lack the very basics in coding. Seeing that you delete productive users and move productive mail databases I would be very concerned when I saw you doing this via "trial and error"... But this is just my point of view...
-/end off topic-
If you do it in the Administrator client, moving a user's mailfile consist of several steps, see https://help.hcltechsw.com/domino/10.0.1/admn_moveamailfilefromoneservertoanother_r.html
Check mail server's access
Create new mail file replica
Add new mail file fields
Monitor new mail file fields
Replace mail file fields
(user has to login to Notes client, or you have to create AdminRequest programmatically)
Push changes to new mail server
Get mail file information for deletion
Approve mail file deletion

Uploading Excel file using VBA to SharePoint

Im struggling to resolve an upload problem direct from excel to sharepoint. I have the right permissions and can upload no problem when hardcoding the URL. Issue I have is all the SharePoint URL's are by Project Number and Description for example:
https://teamzzz.sharepoint.com/sites/Projects/NL001%20%20TEST/10.%20Dispatch
The project is called NL001 in this case. Another example of a URL could be:
https://teamzzz.sharepoint.com/sites/Projects/ZNP001%20%20ANOTHERTEST/10.%20Dispatch
Basically at the point of attempting to upload using my Add in I know the first part of the PATH:
https://teamzzz.sharepoint.com/sites/Projects/
The project id I can find from a cell reference:
NL001
The last part of the URL will always be the same as in:
10.%20Dispatch
My problem is the description after NL001 i.e. "%20%20TEST" (see below):
https://teamzzz.sharepoint.com/sites/Projects/NL001%20%20TEST/10.%20Dispatch
Is there anyway I can use some form of wildcard in the URL for example:
https://teamcde.sharepoint.com/sites/Projects/NL001*/10.%20Dispatch
OR
https://teamcde.sharepoint.com/sites/Projects/NL001%/10.%20Dispatch
The above 2 example dont work but was demonstrating the example I require. Here is my code thus far:
Public Sub CommandButton39_Click()
ProjectFileName = Range("B2").Value
SharePointBasePath = "https://teamcde.sharepoint.com/sites/Projects/"
SharePointEndPath = "10.%20Dispatch/"
ActiveWorkbook.SaveAs Filename:=SharePointBasePath & ThisFile & ".xlsm" & SharePointEndPath
End Sub
Is is possible to utilise a wildcard as the description is not known at time of upload.
Thankyou

Uploading an Excel spreadsheet to Google Sheets

I've been hitting my head on a brick wall with the following lovely conundrum:
The point is to get data from Excel to Google Sheets without uploading files, but going through the URLs. The following handily explain how all that business transpires:
https://www.youtube.com/watch?v=mX2_XNYPGiI
http://ramblings.mcpher.com/Home/excelquirks/exceldocsintegration/excelsheetsv4
I've tried to adapt the following code for the VBA side of things, common to both examples:
Option Explicit
Sub GetDataFromGoogle()
'link to tutorial: https://www.youtube.com/watch?v=mX2_XNYPGiI
Dim link As String
link = "https://docs.google.com/spreadsheets/d/e/2PACX-1vSes7Jb06JRy8KSFyNlpUSzNQxSB_HZay4S8AB2IqzpZP0QdwGO5PFSS-6uzd8v_GsjlkXM31pby2jE/pubhtml"
Sheet4.QueryTables(1).Connection = "URL;" & link
Sheet4.QueryTables(1).Refresh False
Sheet4.Columns(1).ColumnWidth = 10
End Sub
Sub PushDataToGoogle()
Dim link As String
link = "https://docs.google.com/forms/d/e/1FAIpQLSeDHEKJmRDynwOAS4g53T9AVMtpXQkWsRGbAzLpLI7rdsbiFA/formResponse?entry.1155739640=4&fvv=1&draftResponse=%5B%5B%5Bnull%2C1155739640%2C%5B%224%22%5D%0D%0A%2C0%5D%0D%0A%5D%0D%0A%2Cnull%2C%2276341394568976993%22%5D%0D"
'go to that link, refresh it and ensure that the first column isn't too narrow
sheets("Sheet4").QueryTables(1).Connection = "URL;" & link
sheets("Sheet4").QueryTables(1).Refresh True
sheets("Sheet4").Columns(1).ColumnWidth = 10
End Sub
On the Google Sheets side, I used a Form to create a spreadsheet that is both the data source for an Excel import and the destination for the export of data. Replcaing POST and GET in the HTML of the form page is the way to get the destination URL. Subsequently, that URL can be either hardcoded or edited with variables to get various inputs for the "entry.######" part of the URL, and then they are passed on to the sheet in the next available line, which would suit my purposes.
I hit a snag(s) with the oAuth2 part of the operation. From the example on the Desktop Liberation site (second link above), credentials are created from Google and then inserted into a code that authenticates the connection before transmitting the data. As such:
Private Function sheetsOnceOff()
getGoogled "sheets", , _
"1023445954023-hq8gkdcmo9sue822d23gy9ak5hmun27.apps.googleusercontent.com", _
"dX7ABCDEGFBETFWtvX5ShmDfrgrQ"
End Function
If that isn't done, the prior lines of code will just return the main Google login page. I've made the credentials, determined the destination key for the spreadsheet, but I get an error in the getGoogled routine that says:
Runtime-error: '-2147024809 (80070057)': The parameter is incorrect."
parameter values are as follows:
- scope = 'sheets', as it should be
- replacement package = ""
- clientID is OK
- clientSecret is OK
- complain = true
- cloneFromScope = ""
- apikey =""
I'm thinking the replacement package should not be empty if complain is true, but I feel that I'm out of my depth here. At least the logic of what needs to happen makes sense to me, and I've managed to get the transfer from Google Sheets to work fine, but I'm just not sure how to handle the oAuth2 authentication matter.
Thank you in advance.
The following is by no means a complete solution, but it is a rudimentary start. The condition on the following is to be logged into gmail, and it will move one piece of data into Google sheets with its timestamp. It works by direclty opening the page that appears after a user clicks Submit on the form, thus imitating a submission. Link2 opens the spreadsheet where the response is passed.
The downside is that it requires the user to be logged into gmail already and will open a new tab each time a variable is passed, so avoid modifying it with arrays or loops. However, I will try putting together a prior vba gmail project with this to see if can work. More will be forthcoming, but for a hacked together band-aid solution, this will do if someone needs it.
Credits and info here:
[https://stackoverflow.com/questions/3166265/open-an-html-page-in-default-browser-with-vba
https://stackoverflow.com/questions/5915325/open-google-chrome-from-vba-excel
Sub PushDataToGoogle()
Dim chromePath As String
chromePath = """C:\Program Files\Google\Chrome\Application\chrome.exe"""
Dim link As String, link2 As String
link = "https://docs.google.com/forms/d/e/1FAIpQLSeDHEKJmRDynwOAS4gtpXQkWsRGbAzLpLI7rdsbiFA/formResponse?entry.1155739640=4&fvv=1&draftResponse=%5B%5B%5Bnull%2C11557396%224%22%5D%0D%0A%2C0%5D%0D%0A%5D%0D%0A%2Cnull%2C%227634134997568976993%22%5D%0D"
link2 = "https://docs.google.com/spreadsheets/d/1W8A3UuFQTeEwk6-hqERvuIMT_HInySZTNBOIs/edit#gid=11262360"
Shell (chromePath & link)
ThisWorkbook.FollowHyperlink link2
End Sub
Turns out, the solution is considerably simpler, thanks to the Selenium Basic library, available here, with a lot of useful info about how it works:
https://codingislove.com/browser-automation-in-excel-selenium/
A note for your attention: this download needs Selenium GoogleChrome driver version 2.33, the current latest version, to resolve an error with Chrome starting up properly - at least in my case, I need Chrome and not IE working.
In any case, Selenium is a god-send for those in a similar situation. When you download and install Selenium, go into Tools --> References in the VB Editor, and enable the Selenium Type Library.
The following code will do the job:
Option Explicit
Dim myHTML_Element As IHTMLElement
Dim Driver As New WebDriver
Sub seleniumtutorial()
Dim pword As String
Dim link As String, link2 As String
pword = ThisWorkbook.sheets("Sheet1").Range("D10")
Driver.Start "chrome", "https://gmail.com"
Driver.Get ("https://gmail.com")
Driver.FindElementById("identifierId").SendKeys "user#company.com"
Driver.FindElementById("identifierNext").Click
'Driver.Get ("https://sso.diversey.com/nidp/saml2/sso?id=DIVAuthContract30&sid=0&option=credential&sid=0")
Driver.FindElementById("uname").SendKeys "Username"
Driver.FindElementById("pass").SendKeys pword
Driver.FindElementByName("loginButton2").Click
link = "https://docs.google.com/forms/d/e/1FAIpQLSeDHEKJmRDyMt7rdsbiFA/formResponse?entry.1155739640=7&fvv=1&draftR=%5B%5B%5Bnull%2C115B%224%22%5D%0D%0A%2C0%5D%%0A%5D%0D%0A%2Cnull%2C%227634134997568976993%22%5D%0D"
link2 = "https://docs.google.com/spreadsheets/d/1W8A3UuyeEwk6-hqERvuIMT_HInySBOIs/edit#gid=1126962360"
Driver.Get (link)
Driver.Get (link2)
End Sub
link and link2 are, respectively, the page that confirms a response has been submitted and link2 is the link to the spreadsheet that has the list of responses. You can divide this routine into two subs - one logs in the user, and the other creates an array of the items to be fed to google, at which points it just refreshes the same page with the new values, as it cycles through the loop or array.
One more link:
Selenium VBA - exit sub without close browser window
Making the variables public ensures that the browser window doesn't close at the end of the session, or you can declare them inside the first sub if you want it to close. As for credentials, you can either hardcode them or feed them from the spreadsheet, but that's a technicality. Beyond that, it seems like a pretty straightforward routine and it does the job really well.
The syntax of the Selenium library is decidedly more modern than VBA and I'd say quite a bit more powerful

Update IIS 6 IP Restrictions using command line

I found the command line below that is used to add IP addresses to restrict in IIS 7
appcmd set config /section:ipsecurity /+"[ipaddress='10.0.0.1',allowed='false']"
Is there an equivalent command for IIS 6?
Thanks!
No, there's no built-in Windows command to do it. You can find evidence of scripts that people have written to mitigate for this.
Ultimately, you want to modify a metabase entry called IPSecurity. Here's the thing: this IPSecurity entry can be set up at the top level (W3SVC service) all of the way down to individual files. So, you can define security for any of:
Service
Site
VDir
Folder
File
The example in your question is service-wide, so you'd want to target IIS://localhost/W3SVC. If you wanted to configure only the default website, you'd target IIS://localhost/W3SVC/1/Root.
Once you know what level you want to modify, you need to identify what the course of action is for a matching IP. You clearly want to block. That means you'll need to modify the IPDeny List.
Now you just need to write a script in the language of your choice that connected to the metabase via ADSI and modifies the IPDeny list to include the additional IP.
I've modified the one from the MSDN page to take an argument:
Dim SecObj
Dim MyIPSec
Dim IPList
Set SecObj = GetObject("IIS://LocalHost/W3SVC")
Set MyIPSec = SecObj.IPSecurity
If (FALSE = MyIPSec.GrantByDefault) Then
MyIPSec.GrantByDefault = TRUE
End If
if WScript.Arguments.Count = 0 then
WScript.Echo "Missing IP Address"
WScript.Quit(1)
end if
' WScript.Echo "Adding " & WScript.Arguments(0)
IPList = MyIPSec.IPDeny
Redim Preserve IPList (Ubound(IPList)+1)
IPList (Ubound(IPList)) = WScript.Arguments(0)
MyIPSec.IPDeny = IPList
SecObj.IPSecurity = MyIPSec
SecObj.Setinfo
If you save this as blockip.vbs, you can call it with:
wscript blockip.vbs 10.0.0.1
FYI, This works fine with IIS6, but works once, then fails after the list exists, on Win7 (IIS 7.5).

HttpPostedFile.FileName - Different from IE

When I upload a file to a site using the ASP:File control the FileName property is different in IE and Firefox. In Firefox, it just provides the name of the file, but IE provides the full path to the file.
I have worked around this by adding the code:
Dim FileName As String = file.FileName
If FileName.LastIndexOf("\") > 0 Then
FileName = FileName.Substring(FileName.LastIndexOf("\") + 1)
End If
But I'm not sure why that would be different between the different browsers. Does anyone know the reason for this?
Thanks.
A simple workaround for this tested in IE and Chrome
new FileInfo(myHttpPostedFileBase.FileName).Name
This will ensure you always get just the file name even if the path is included.
This is a security/privacy concern, firefox/mozilla is doing it right and you will not get a way to get the full path without an add-in, applet, silverlight, flash or some other mechanism.
Here is more info on Mozilla's stance:
https://developer.mozilla.org/en/Updating_web_applications_for_Firefox_3
See the section on Security Changes->File upload fields
I hope IE will follow suit so we have a consistent and secure environment.
In IE8, this behavior has changed and it will ONLY pass the file name, not the full path. ;-)
Details and link to the IE Blog post discussing the change in IE8:
Link
Serverside apps looking to parse out the filename should check for, but not expect there to be backslashes in the filename.
IE8 user setting override:
Link
You also can use Path.GetFileName(File.FileName) that return only file name.
Example:
Dim File As HttpPostedFile = context.Request.Files("txtFile")
' let's FileName is "d:\temp\1.txt"
Dim FileName As String = Path.GetFileName(File.FileName)
' FileName will be "1.txt"

Resources