Provided that I have the mail file name and the server, how do I retrieve the fully qualified name of the user it corresponds to in the form "CN=xxx/O=yyy" using LotusScript?
To start with, I have the user's username - the part before @ in the email: i.e. [email protected]
I also know server, on which this user is registered, so I use Registration.GetUserInfo like this:
Dim reg as New NotesRegistration
reg.RegistrationServer = "CN=myserver/O=mydomain"
Call reg.GetUserInfo("user1", mailserver$, mailfile$)
The question is: how out of this data I can get the full name of the user?
Here's a quick implementation of Jonesys suggestion:
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
A few words of caution:
CANONICALIZE
picks its values from the current ID, not the domino directory - the input mailserver
must be in either abbreviated or canonicalized form for this to work.MailFile
field may or may not include the .nsf
extension.If you need to do these lookups frequently, a computed lookup table or a view in the Domino Directory is probably the most efficient solution.