如何在 Lotus Notes 中获取邮件文件所有者的全名
-
20-09-2019 - |
题
假设我有邮件文件名和服务器,如何使用 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
我结束了这个解决方案(如我知道哪个是地址簿服务器的用户):
macro$ = { @DbLookup( "" ; "} & regServer & _
{" : "names.nsf" ; "($Users)" ; "} & shortName & {" ; "FullName" ) }
Dim namelist As Variant
namelist = Evaluate ( macro$ )
commonName = namelist(0)
其他提示
以下是 Jonessys 建议的快速实施:
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 目录中的视图可能是最有效的解决方案。
如果您有邮件文件名,为什么不使用查找到NAB,作为你的钥匙,并得到全名呀?
如果您有互联网地址,你可以只使用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
不隶属于 StackOverflow