0

假设我有邮件文件名和服务器,我如何使用 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$)

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

4

4 回答 4

3

这是琼斯建议的快速实施:

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 目录中的视图可能是最有效的解决方案。

于 2010-02-05T09:02:52.370 回答
1

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

于 2010-01-26T14:55:00.587 回答
0

如果您有 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
于 2010-02-05T14:30:06.210 回答
0

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

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

Dim namelist As Variant

namelist = Evaluate ( macro$ )

commonName = namelist(0)
于 2010-02-05T16:06:20.973 回答