Switching ID's via script

I have created a script to automate the following procedure. We are creating replicas of each users personal address book on a server so that they can access it via citrix. The users do not have create access on that server so we first switch to a user id that has access, create the replica, then switch back to the users id. this is being run on laptops. So far, the switching to the 1st id and creation of the replica works but I then get an error immediately after the replica is created and the id does not switch back (I guess because the error stops the script from running at that point?).

Here’s the code:

Sub Click(Source As Button)

Dim workspace As New NotesUIWorkspace

Dim db As NotesDatabase  

Dim pass As Variant

REM {Switch User ID to Power User and pass through password	}

pass = "MYPassword"

Dim reg As New NotesRegistration

Dim UserName As String

UserName = reg.SwitchToID("o:\LNotesIDs\jjones.id", pass)

If UserName="" Then Msgbox "Login Failure" Else Msgbox "You are now logged in as "+username + ". A personal address book replica will now be created on the SMFMAIL1 server"

REM {Create Personal Address Book Replica on SMFMAIL1. Users initials are added to filename.}

UserP = workspace.Prompt(PROMPT_OKCANCELEDIT, _

"User Initials Prompt", "Please enter the users 3 character initials.", "", "")

UserP2 = "Mail\\Staff_Adress\\" + Userp + "names.nsf"

Dim name1 As New NotesDatabase("", "names.nsf")

Set db = name1.CreateReplica("SMFMAIL1//SMF", UserP2)

“THIS IS WHERE I GET THE ERROR ALTHOUGH THE CODE DOES INDEED CREATE THE REPLICA. I NEVER GET THE PROMPT BELOW BUT INSTEAD GET THE ERROR MESSAGE”

Messagebox "Address Book Replica Created on SMFMAIL1. Switching back to users ID...", MB_OK, "Success"

REM {Switch ID back to original user}

Dim IDFile As Variant

Dim Datapath As String

Datapath = "C:\Notes\Data\"

IDFile = workspace.OpenFileDialog(False,"Choose ID File","ID Files | *.id",Datapath)

Call reg.SwitchToID(IDFile(0))

Msgbox "You are now logged in as "+IDFile

End Sub

Does anyone see anything that may be causing the following error immediately after the replica is created?

“Notes Error: Note item not found c:\notes\data\names.nsf”

Thanks in advance

Subject: Switching ID’s via script

Instead of switching ids, use RunOnServer to launch a separate agent that operates with the required permissions. If you have parms to pass to the agent, they can be passed by creating and saving a document, and using the ParameterNoteID optional parameter to tell the agent where to look for its data.

Subject: Switching ID’s via script

Here is an solution…http://www-1.ibm.com/support/docview.wss?&uid=swg21155739

Subject: Switching ID’s via script

Hi,

I think this procedure is very complicated.

Have you checked the option upgrade users to roaming?

I believe it will do the job for you.

HTH

Daniel