如何在Lotus Notes中获取邮件文件所有者的全名

时间:2010-01-15 19:13:04

标签: lotus-notes lotusscript userinfo

如果我有邮件文件名和服务器,如何使用LotusScript以“CN = xxx / O = yyy”的形式检索它对应的用户的完全限定名称?

首先,我有用户的用户名 - 电子邮件中@之前的部分:ie user1@example.com

我也知道这个用户注册的服务器,所以我使用了这样的Registration.GetUserInfo:

Dim reg as New NotesRegistration
reg.RegistrationServer = "CN=myserver/O=mydomain"
Call reg.GetUserInfo("user1", mailserver$, mailfile$)

问题是:如何从这些数据中获取用户的全名?

4 个答案:

答案 0 :(得分:3)

以下是Jonesys建议的快速实施:

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

请注意几点:

  • CANONICALIZE从当前ID中选择其值,而不是domino目录 - 输入mailserver必须采用缩写或规范化形式才能生效。
  • MailFile字段可能包括 包含.nsf扩展名。
  • 我认为文件名在Windows上不区分大小写,但可能在其他平台上。

如果您需要经常进行这些查找,那么计算查找表或Domino目录中的视图可能是最有效的解决方案。

答案 1 :(得分:1)

如果您有邮件文件名,为什么不使用它作为您的密钥查找NAB并以这种方式获取全名?

答案 2 :(得分:0)

如果你有互联网地址,你可以使用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

答案 3 :(得分:0)

我最终得到了这个解决方案(因为我知道哪个是用户的AddressBook服务器):

macro$ = { @DbLookup( "" ; "} & regServer & _
         {" : "names.nsf" ; "($Users)" ; "} & shortName & {" ; "FullName" ) }

Dim namelist As Variant

namelist = Evaluate ( macro$ )

commonName = namelist(0)
相关问题