About This Code
Brief Description:
Get Your Enterprise NAB from the current database ( shorten your code )
Notes Version:
R6.x, R8.x, R7.x
Last Modified:
03 Nov 2008
OpenNTF Disclaimer
All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.
Code / Description
Function GetEnterpriseNAB( default As String ) As NotesDatabase
' returns the NAB from the server the current Db is on
' posted to http://www.openntf.org/projects/codebin/codebin.nsf/CodeBySubCategory/808CDC4680D8BF37862574EF006EDD01
' written by Mike Mortin
Dim s As New NotesSession
Dim db As NotesDatabase
Dim server As String
Dim nname As NotesName
' set the default
If default = "" Then default = "Admin01/Operations/CA"
' get our parent server to get the NAB
Set db = s.CurrentDatabase
Set nname = New NotesName(db.Server)
server = nname.Common
' now, use default server if we are local
If server = "" Then server = default
' finally, grab names.nsf from that server
Set GetEnterpriseNAB = New NotesDatabase(server, "names.nsf")
End Function
Usage / Example
Rather than hardcoding your admin server all over the place, use this simple function called from your common script library to obtain a NAB from the current database. If the current database is local you can specify a server to use instead, or use a single hardcoded default server from within this function.
Dim nab as NotesDatabase
set nab = GetEnterpriseNAB("")
or
set nab = GetEnterpriseNAB("Admin02/Operations/CA")