添加服務器鏈接

Sub Click(Source As Button)
 On Error Goto ef
 Dim session As New NotesSession
 Dim dbNAB As NotesDatabase
 Dim dc As NotesDocumentCollection
 Dim doc As NotesDocument, docTemp As NotesDocument
 Dim strSearch As String
 
 Set dbNab = session.GetDatabase( "", "")
 
 Call dbNab.Open( "", "names.nsf" )
 
 strSearch = { ( form = "local" | form = "remote" ) & ( Destination = "TEST02.CN.ABB.COM/SRV/ABB" | Destination = "CN=TEST02.CN.ABB.COM//OU=SRV/O=ABB" ) }
 
 Set dc = dbNAB.Search( strSearch, Nothing, 0 )
 
 If dc.count > 0 Then
  Set doc = dc.getfirstdocument
  
  With doc
   .Destination = "TEST02.CN.ABB.COM/SRV/ABB"
   .LanPortName = "TCPIP"
   .PortName = "TCPIP"
   .OptionalNetworkAddress = "10.138.250.27"
   .PhoneNumber = "10.138.250.27"
   .Owner = session.username
   .documentaccess = "[NetModifier]"
   Call .computewithform( True, False )
   Call .save( True, True )
   Msgbox "Connection document has been updated"   
  End With
  Set doc = dc.GetNextdocument( doc )
  Do Until doc Is Nothing
   Set docTemp = doc
   Set doc = dc.GetNextdocument( doc )
   Call docTemp.remove( True ) 
  Loop
 Else
  Set doc = dbNab.CreateDocument  
  
  With doc
   .form = "local"
   .type = "Connection"
   .connectionLocation = "*"
   .connectionType = "0"
   .Source = "*"
   .Destination = "TEST02.CN.ABB.COM/SRV/ABB"
   .LanPortName = "TCPIP"
   .PortName = "TCPIP"
   .OptionalNetworkAddress = "10.138.250.27"
   .PhoneNumber = "10.138.250.27"
   .Owner = session.username
   .documentaccess = "[NetModifier]"
   Call .computewithform( True, True )
   Call .save( True, True )
  End With
  Msgbox "Connection document has been created"
 End If
 
 Exit Sub
ef:
 Msgbox "error is" & Error$ & "”;and in line " & Erl, 16, "Error"
 Exit Sub
 
End Sub 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章