プロが教える店舗&オフィスのセキュリティ対策術

WindowsXP SP1でNotes6.5.4を使用しています。
海外のサーバー上にあるDBを開こうとしています。
個人アドレス帳の接続文書にそのサーバー名とIPアドレスを追加すると開けるようになりますが、対象者が100名以上いるため、DBのリンクのようにクリックすると一括で接続文書が追加される方法はありますでしょうか。もしくは接続文書のバッチファイルは作成可能なのでしょうか。
よろしくお願いいたします。

A 回答 (3件)

こんな感じでどうでしょう??


ボタンを作成してその中に記述してください。
-----
(Options)には以下を記述。
Option Compare Nocase
Option Declare

(Declarations)には以下を記述。
Const MB_YESNO = 4
Const MB_ICONQUESTION = 32
Const IDYES = 6
Dim session As NotesSession
Dim workspace As NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim TCPIP_Port As String

Sub Click(Source As Button)
Dim servername As String
Dim IPAddress2 As String
Dim PartitionCode As String
Dim DirectoryName As String

On Error Goto errorHandler
Set session = New NotesSession
Set workspace = New NotesUIWorkspace
Set db = New NotesDatabase("", "names")
Set view = db.GetView("Connections")

' Customize by setting the values below
' Usually the directory name uses the Partition Code as part of its structure
servername = "ここにドミノサーバー名を入れる"
IPAddress2 = "ここにドミノサーバーのipアドレスもしくはホスト名を入れる"
DirectoryName = ""
' End of customization section

Call createOrUpdateConDoc(servername, IPAddress2)

Print "処理完了 !"

Exit Sub

errorHandler:
Messagebox "Error in Click event " & Err() & ": " & Error()
Exit Sub

End Sub

Sub addNewConDoc(dest As String, address As String)

On Error Goto errorHandler

If Messagebox(" " & dest & " の接続文書を新たに作成します。 " _
& " ", MB_YESNO + MB_ICONQUESTION, _
"Create a Server Connection Document") <> IDYES Then Exit Sub
Print "Creating a Server Connection document for " & dest & " at " & address " in your NAMES.NSF file."

Set uidoc = workspace.ComposeDocument("", "names", "local")

Call uidoc.FieldSetText("ConnectionType","0") 'Set for Lan connection
Call uidoc.FieldSetText("Destination",dest) 'Set destination
Call uidoc.FieldSetText("OptionalNetworkAddress",address) 'Set address

If TCPIP_Port = "" Then Call findTCPIP_Port 'Find the first enabled TCPIP port and use it for the port
Call uidoc.FieldSetText("LanPortName",TCPIP_Port)

Call uidoc.FieldSetText("ConnectionRecordFirst", "1") 'Set usage priority
Call uidoc.FieldSetText("ConnectionLocation","*") 'Set Location
Call uidoc.FieldSetText("Source", session.UserName) 'Set only for this user
Call uidoc.FieldSetText("Comments", "スクリプトにより自動作成しました。") 'Just so the user knows where it came from

Call uidoc.Save
Call uidoc.Close
Exit Sub

errorHandler:
Messagebox "Error in addNewConDoc " & Err() & ": " & Error()
Exit Sub

End Sub

Sub createOrUpdateConDoc(dest As String, address As String)
On Error Goto errorHandler

Print "Looking for a Server Connection document for " & dest & " in your Address Book"
Set doc = view.GetDocumentByKey(dest) 'Lookup by the server name
If doc Is Nothing Then
Call addNewConDoc(dest, address) 'Not found, so add it
Else ' Otherwise, update it
If(doc.Remove(True)=True) Then
Messagebox("古い文書を削除しました。")
Call addNewConDoc(dest,address)
Else
Messagebox("古い文書を削除できませんでした。" & dest & " を手動で削除してからもう一度ボタンを押してください。")

End If

End If
Exit Sub

errorHandler:
Messagebox "Error in createOrUpdateConDoc " & Err() & ": " & Error()
Exit Sub

End Sub

Sub updateConDoc (dest As String, address As String)
If Messagebox("A Server Connection document for " & dest & " was found in your Address Book. " _
& "Do you wish me to update it?", MB_YESNO + MB_ICONQUESTION, _
"Update a Server Connection Document") <> IDYES Then Exit Sub
Print "Updating a Server Connection document for " & dest & " at " & address " in your NAMES.NSF file."

doc.Comments = doc.Comments & Chr(10) & " Updated by program. Old Destination server address was " & doc.OptionalNetworkAddress(0)
doc.OptionalNetworkAddress = address
doc.PhoneNumber = address
'For this version, update the port name also
If TCPIP_Port = "" Then Call findTCPIP_Port 'Find the first enabled TCPIP port and use it for the port
doc.LanPortName = TCPIP_Port
doc.PortName = TCPIP_Port

Call doc.save(False, True, False)
End Sub

Sub findTCPIP_Port
'Look for a TCPIP port that is enabled
On Error Goto errorHandler
Dim ports As String
Dim aport As String
Dim portstring As String
Dim wordstart As Integer
Dim wordlen As Integer
Dim wordstop As Integer

ports = session.GetEnvironmentString("Ports", True) 'Get a list of enabled ports
wordstart = 1

Do
wordstop = Instr(wordstart, ports, ",") 'Look for the common delimited words
wordlen = wordstop - wordstart
If wordlen <= 0 Then
aport = Trim(Mid(ports, wordstart)) 'Word goes to end of string
Else
aport = Trim(Mid(ports, wordstart, wordlen)) 'Word in the midst of the string
End If
wordstart = wordstop+1
portstring = session.GetEnvironmentString(aport, True) 'Get the information on the port in question
If Left(portstring,3) = "TCP" Then 'Driver name is first three characters. Is it the TCPIP driver?
TCPIP_Port = aport
Exit Sub
End If
Loop Until wordlen <= 0
TCPIP_Port = "TCP" 'Use the driver name. This seems to work.
Exit Sub

errorHandler:
Messagebox "Error in findTCPIP_Port " & Err() & ": " & Error()
Exit Sub

End Sub

---

この回答への補足

joker1969さん、ご回答ありがとうございます。
不勉強で申し訳ないのですが、ご回答いただいた内容でわからない部分があります。

>ボタンを作成して
→[作成]-[ホットスポット]-[ボタン]でボタンを作成、でよろしいでしょうか。

>その中に記述してください。
>(Options)には以下を記述。
>(Declarations)には以下を記述。
→記述方法を教えていただけますでしょうか。

補足日時:2008/02/14 13:59
    • good
    • 0

ご使用のPCには「ノーツクライアント」の他に「ドミノデザイナー」を導入されてますでしょうか?


導入していない場合、ボタンの実行のプルダウンリストはグレーアウトのまま、シンプルアクションのみが可能となります。
    • good
    • 0
この回答へのお礼

joker1969さん
ご指摘の通り、ドミノデザイナーが導入されておりませんでした。
いろいろ教えていただきましてありがとうございました。

お礼日時:2008/02/14 17:39

>>ボタンを作成して


>→[作成]-[ホットスポット]-[ボタン]でボタンを作成、でよろしいでしょうか。

はい、それで構いません。

そのボタンの実行を「式」から「LotusScript」に変更してください。
オブジェクトタブの中に「(Options)」「(Declarations)」等が表示されるはずです。
Clickイベントもあるはずなので、ここには先に記載したSub Click()~End Subの内容をコピペしてください。
他の4つサブルーチンはそのままコピペで構いません。

この回答への補足

joker1969さん、ふたたびご回答ありがとうございます。

実行を選択するボックスが「クライアント」「シンプルアクション」のままグレーアウトしているため、Notes管理者でないとアクティブにならない箇所のようです。。。
とても詳しくご説明いただいたのに申し訳ありません。
ありがとうございました。

補足日時:2008/02/14 15:53
    • good
    • 0
この回答へのお礼

不勉強な質問にとても詳しくご回答・ご説明いただきましてありがとうございました

お礼日時:2008/02/14 15:57

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!