Come ottenere nome e cognome del proprietario del file di posta in Lotus Notes
-
20-09-2019 - |
Domanda
A condizione che ho inserito il nome del file di posta e il server, come faccio a recuperare il nome completo dell'utente corrisponde nella forma "CN = xxx / O = yyy" utilizzando LotusScript?
Per cominciare, ho il nome utente dell'utente - la parte prima @ nella e-mail: vale a dire user1@example.com
So anche server su cui è registrato l'utente, per cui uso Registration.GetUserInfo in questo modo:
Dim reg as New NotesRegistration
reg.RegistrationServer = "CN=myserver/O=mydomain"
Call reg.GetUserInfo("user1", mailserver$, mailfile$)
La domanda è: come fuori di questi dati posso ottenere il nome completo dell'utente
?Soluzione 4
Ho finito con questa soluzione (come so che è il server AddressBook per l'utente):
macro$ = { @DbLookup( "" ; "} & regServer & _
{" : "names.nsf" ; "($Users)" ; "} & shortName & {" ; "FullName" ) }
Dim namelist As Variant
namelist = Evaluate ( macro$ )
commonName = namelist(0)
Altri suggerimenti
Ecco una rapida implementazione di Jonesys suggerimento:
Function getMailFileUser(mailserver As String, mailfile As String) As String
On Error Goto errorthrower
Dim session As New notessession
Dim dd As NotesDatabase
Forall candidate_dd In session.AddressBooks
If candidate_dd.Server<>"" And candidate_dd.IsPublicAddressBook Then
Set dd = candidate_dd
Exit Forall
End If
End Forall
If dd Is Nothing Then Error 1978,"Failed to find Domino Directory"
If Not dd.IsOpen Then Call dd.Open("","")
Dim userdocs As NotesDocumentCollection
Set userdocs = dd.Search({form="Person" & }& _
{@name([CANONICALIZE];MailServer)=@name([CANONICALIZE];"} & mailserver & {") & } &_
{MailFile="} & mailfile & {"},Nothing,1)
Dim userdoc As NotesDocument
Set userdoc = userdocs.GetFirstDocument
If Not userdoc Is Nothing Then
getMailFileUser = userdoc.FullName(0)
Else
getMailFileUser=""
End If
Exit Function
ErrorThrower:
Error Err, Error & Chr(13) + "Module: " & Cstr( Getthreadinfo(1) ) & ", Line: " & Cstr( Erl )
End Function
Qualche parola di cautela:
-
CANONICALIZE
prende i propri valori dalla ID corrente, non la directory domino -. Ilmailserver
ingresso deve essere sia in forma abbreviata o canonicalized per questo lavoro - Il campo
MailFile
possono o non possono includere l'estensione.nsf
. - Non credo che il nome del file è case sensitive su Windows, ma potrebbe essere su altre piattaforme.
Se avete bisogno di fare spesso queste ricerche, una tabella di ricerca calcolata o una vista in indirizzi di Domino è probabilmente la soluzione più efficiente.
Se avete il nome del file di posta, perché non fare una ricerca in NAB utilizzando tale come la vostra chiave e ottenere il nome completo in quel modo?
Se avete l'indirizzo Internet si può semplicemente utilizzare la classe NotesName.
Dim s As New NotesSession
Dim userName As NotesName
Dim canonicalName as String
Set userName = s.CreateName("user@yourdomain.com")
'You can use the previous line or the next line to get the NotesName object
'Set userName = new NotesName("user@yourdomain.com")
canonicalName = userName.Canonical