【问题标题】:How to get full name of the owner of mail file in Lotus Notes如何在 Lotus Notes 中获取邮件文件所有者的全名
【发布时间】:2010-01-15 19:13:03
【问题描述】:

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

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

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

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

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

【问题讨论】:

    标签: lotus-notes lotusscript userinfo


    【解决方案1】:

    以下是 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 表示好代码。我没有使用它,但仍然是一个很好的例子。谢谢。
    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

      如果您有 Internet 地址,则可以使用 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
      

      【讨论】:

      • 这对我不起作用。 MessageBox(userName.Canonical) 显示电子邮件。
      • 仅使用 Internet 地址实例化 NotesName 在这里无济于事。
      【解决方案4】:

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

      macro$ = { @DbLookup( "" ; "} & regServer & _
               {" : "names.nsf" ; "($Users)" ; "} & shortName & {" ; "FullName" ) }
      
      Dim namelist As Variant
      
      namelist = Evaluate ( macro$ )
      
      commonName = namelist(0)
      

      【讨论】:

        猜你喜欢
        • 2014-10-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-04-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多