Script section: Executing projects on UMRA Service
The database connection is initialized and the UMRA COM object is connected to the UMRA Service. Now the loop is implemented. For each returned database record, the variables list of the UMRA COM object is initialized and the UMRA Service is requested to execute the UMRA project that creates the user account.
While adoRS.EOF = False
Umra.SetVariableText "%Firstname%", adoRS("FirstName")
Umra.SetVariableText "%LastName%", adoRS("LastName")
RetVal=Umra.ExecuteProjectScript("CreateAccount")
RetVal=Umra.GetVariableText("%Username%", Username)
RetVal=Umra.GetVariableText("%Password%", UserPassword)
wscript.echo "User created: " & Username & " - " & UserPassword
adoRS.MoveNext
Wend
The While … Wend construction is used for the loop. The loop is terminated when no more records are found: when adoRS.EOF=False no longer holds.
For each cycle of the loop, first the list with variables maintained by the UMRA COM object is initialized. The method SetVariableText is used. The method takes two arguments: the name of the variable (%FirstName%) and the value. The value is copied from the record set: adoRS("FirstName"). Here, FirstName is the name of the column of the database table from which the value must be obtained. Using this method, the %FirstName% and %LastName% UMRA variables are initialized.
With method Umra.ExecuteProjectScript the UMRA Service is requested to execute the passed project. With some other information, the list with variables and values is sent to the UMRA Service. The UMRA Service will check the access rights of the requesting user account, load the project and execute the script of the project. The variables updated or generated by the script of the project are returned to the UMRA COM object. On success, the return value is zero.
The Umra.GetVariableText method of the UMRA COM object is now used to retrieve the values of the variables %UserName% and %Password%. The values are stored in the script variables Username and UserPassword. With the standard wscript.echo method, the user name and password of the created user account is presented to the end user.

For each user account created, the message above is shown. In a more practical script, this is probably not convenient and should be changed.
Finally, the record set moves to the next record: adoRS.MoveNext.
|