Manage Learn to apply best practices and optimize your operations.

Retrieve List Of Servers On All Ports

This LotusScript function makes calls to the Notes API to retrieve a list of
Domino servers from all ports. It returns a Variant containing an array of
server names in canonical format that you can iterate through to suit your

For example, to display a list of common names of all servers in a messagebox,
you can use the following button code:

Sub Click(Source As Button)
Dim n As NotesName
Dim sMsg$
Dim vServerList

' get list of servers
sMsg$="Server List:" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

' loop over server list and build a string we can display

Forall s In vServerList
Set n = New NotesName(s)
sMsg$=sMsg$ & n.Common & Chr(13) & Chr(10)
End Forall

' show the list in a messagebox
Msgbox sMsg$, 0, "Server List Demo"
End Sub

' Notes API declares and constants
Declare Function NSGetServerList% Lib "nnotes" (Byval dwPortName&,
Declare Function ListGetText% Lib "nnotes" (Byval dwList&, Byval
nPrefixDataType%, Byval nEntryNumber%, dwRetTextPointer&, nRetTextLength%)
Declare Function OSTranslate% Lib "nnotes" (Byval nTranslateMode%, Byval
dwIn&, Byval nLength%, Byval lpszOut$, Byval nOutLength%)
Declare Function OSLockObject& Lib "nnotes" (Byval nHandle%)
Declare Function OSUnlockObject% Lib "nnotes" (Byval nHandle%)
Declare Function OSMemFree% Lib "nnotes" (Byval nHandle%)


Function GetServerList() As Variant
Dim lpszServer$
Dim szArray() As String
Dim hList%, nStatus%, nCount%, nLength%
Dim dwList&, dwHold&

' get a list of known servers on all ports
nStatus%=NSGetServerList(0, hList%)

' be sure our API call returned a handle to our list buffer
If nStatus%=0 And hList% <> 0 Then
' initialize our results array
Redim szArray(0)

' lock down our memory handle

Do While nStatus%=0
' get a server in the list
nStatus%=ListGetText(dwList&, 0, nCount%, dwHold&, nLength%)

If nStatus%=0 And nLength%>0 Then
' intialize the string to pass to the API

' translate the results to the native charset
Call OSTranslate(OS_TRANSLATE_LMBCS_TO_NATIVE, dwHold&, nLength%, lpszServer$,

'populate an array with the results
Redim Preserve szArray(nCount)
End If



' free our lock on the list
Call OSUnlockObject(hList%)

' free the handle allocated by NSGetServerList
Call OSMemFree(hList%)

End If

' return results to caller

End Function

Dig Deeper on Domino Resources - Part 7

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.



  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...