例: VerifyPassword method

次のエージェントは、最初に既存のパスワードを検証してから、パスワードを環境変数として保存します。

Sub Initialize
  Dim session As New NotesSession
  Dim ws As New NotesUIWorkspace
  REM Verify password
  pwhashed$ = session.GetEnvironmentString("SecretPassword")
  If pwhashed$ <> "" Then
    pw$ = ws.Prompt(PROMPT_PASSWORD, "Password", _
    "Secret password")
    If Not session.VerifyPassword(pw$, pwhashed$) Then
      Messagebox "Password not correct",, "Verification failed"
      Exit Sub
    End If
  End If
  REM Create or change password
  pw$ = ws.Prompt(PROMPT_PASSWORD, "Password", _
  "New secret password")
  If pw$ = "" Then Exit Sub
  pwverify$ = ws.Prompt(PROMPT_PASSWORD, "Password", _
  "Verify new secret password")
  If pwverify$ = "" Then Exit Sub
  If pw$ = pwverify$ Then
    pwhashed$ = session.HashPassword(pw$)
    Call session.SetEnvironmentVar("SecretPassword", pwhashed$)
  Else
    Messagebox "Password not recorded",, "Verification failed"
  End If
End Sub