Manage Learn to apply best practices and optimize your operations.

Move User To A New Home Server

This is code for two buttons that you can mail to a user to change the settings
on their workstation to point to a new home server. The first button is script
that uses their common name to do a lookup in the Domino Directory to determine
their home server and mail file location (make the change to their person
document before mailing the buttons). It then edits all location documents to
insert the new mail server and mail file. It provides for skipping modifying
the mail file for onelocation document (we use one location document for the
local mail file and therefore don't want that path modified. The code also
sets some environmental varialbes that are used by the second button. It also
sends a log to a specified database.

The second button is formula language (I couldn't figure out how to do it in
script - definitely respond if you know a way). It uses the environmental
variable set in the first button to delete the old mail file icon from the
workspace and add one from the new server. (I haven't tried this with the

I got the name lookup part from Robert Bell's submission to this site titled "A
function to simulate R5's @NameLookup in R4.6" - thank you Robert, that's the
second tip of yours that's come in handy.

The icon button is based on Robert Carpenter's tip here titled "Remove and add
database icons" - thank you Robert

Unfortunately I can't remeber who to thank for the the modification of all
location documents. There was an article (perhaps in Domino Advisor) on how to
go thorugh all location and connection documents and change the domain. I
based it on that.

As you can see, most of this has been pilfered but it did take quite a bit of
time to assemble so I thought I'd provide it here in the hopes of saving
someone else that time. Enjoy!
Button #1:

' System variables -> DO NOT CHANGE!!!!
Const VIEW_LOCATION_NAME = "($Locations)"

'Application variables -> EDIT THESE ONES!!!!
Const DO_NOT_MODIFY_NAME = "On The Road" 'This is the value of the location
document that should not be changed
Const LOG_DATABASE_ADDRESS = "FBR User Migration Log/EME" 'Address for log
reports to be mailed to

Sub Click(Source As Button)

' This prompt seems to only work with Notes R5 Clients. REM out the next 7
lines for sending to Notes 4.6 users.
' Prompt user to proceed
' Dim ws As New NotesUIWorkspace
' Dim askme As Variant
' askme = ws.Prompt(PROMPT_YESNO, "Continue?", "Your computer will now be
configured to access the new Notes Server. You must be connected to the
network for this to work. If you are not on the network, click 'No,' connect
to the network and then press the button again. Otherwise, click 'Yes' to
' If (askme = 0) Then
' Exit Sub
' End If

' Set up logging for this session
Dim currentLog As NotesLog
Set currentLog = New NotesLog("User Migration")

' Get variables needed for this script
Dim ws As New NotesUIWorkSpace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim UserName As String
Dim UserNameKey As String
Dim NewMailServer As String
Dim NewMailFile As String
Dim tmpUserName As String

Print "Looking up information. Please wait..."

UserName = session.Commonusername
UserNameKey = Lcase(UserName)
NewMailServer = LookupUser (UserNameKey, "mailserver", "0")
NewMailFile = LookupUser (UserNameKey,"mailfile","0")
Print "Final Results: User = " & UserName & " * MailServer = " & NewMailServer
& " * MailFile = " NewMailFile

'End get variables

'enviornmental variables used by the button to switch workspace icons
Call session.SetEnvironmentVar( "tmpNewMailServer", NewMailServer )
Call session.SetEnvironmentVar( "tmpNewMailFile", NewMailFile )

' Start Logging
Call currentLog.OpenMailLog (LOG_DATABASE_ADDRESS, UserName )
Call currentLog.LogAction( "User name determined to be: " & UserName )
Call currentLog.LogAction( "New mail server: " & NewMailServer )
Call currentLog.LogAction( "New mail file: " & NewMailFile )

' Begin edit of location documents
Dim dbNab As NotesDatabase
Dim view As NotesView
Dim note As NotesDocument
Dim sNamesLine As String
Dim sLocationName As Variant
Dim nPos As Integer
Dim bNeedsUpdate As Integer
Dim bLocationModified As Integer

On Error Resume Next

' first, get the local NAB
sNamesLine = session.GetEnvironmentValue("names",True)

nPos = Instr(sNamesLine, ",")
If nPos > 0 Then
sNamesLine = Left$(sNamesLine, nPos-1)
sNamesLine = "names.nsf"
End If

Set dbNab = New NotesDatabase( "",sNamesLine )
Call currentLog.LogAction( "Personal Address Book opened." )

If Not(dbNab.isOpen) Then
Messagebox("Could not locate your Name & Address book.")
Call currentLog.LogError( 0, "Could not locate personal address book." )
Exit Sub
End If

' update all location documents
Set view = dbNab.GetView(VIEW_LOCATION_NAME)
If (view Is Nothing) Then
Messagebox("Your Name & Address book is missing a required view.")
Call currentLog.LogError( 0, "Personal address book is missing a required
view." )
Exit Sub
End If

Set note = view.GetFirstDocument

'enviornmental variables used by the button to switch workspace icons -
requires that first location document have the correct information
Call session.SetEnvironmentVar( "tmpOrigMailServer", note.MailServer(0) )
Call session.SetEnvironmentVar( "tmpOrigMailFile", note.MailFile(0) )

While Not(note Is Nothing)
Call currentLog.LogAction( "Modifying the " & sLocationName & " location." )

If Lcase(sLocationName) <> Lcase(DO_NOT_MODIFY

Dig Deeper on Domino Resources



  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...

  • HTML cheat sheet

    This is a really cool cheat sheet if you're looking to learn more about HTML. You'll find just about everything you every wanted ...

  • Carol Woodbury: Security

    Carol Woodbury