当注册用户用户名格式为user/ou2/ou1/ou/o,那么使用企业通讯录,希望在公司层次结构中,很清晰显示出来。
实例代理程序:
%REM
Agent 增加公司层次名称
Created 2011-12-18 by LILI
Description: Comments for Agent
%END REM
Option Public
Option Declare
Sub Initialize
Dim se As New NotesSession '定义变量
Dim db As NotesDatabase
Dim col As NotesDocumentCollection
Dim doc As NotesDocument
Dim selection As String
Dim i As Integer
Dim datetime As New NotesDateTime("")
Dim UsrName As NotesName
Set db = se.Getdatabase( se.Currentdatabase.Server , "names.nsf") '打开所在服务器的names
selection = {Form = "Person" & level0=""} '使用Notes公式,选择Person表单,并level0为空
Set col = db.Search(selection,datetime,0) '查询符合条件的文档集
Set doc = col.GetFirstDocument '打开第一个文档
i = 1 '用于计算修改文档数目
While Not( doc Is Nothing )
Call doc.Copytodatabase( se.Currentdatabase )
Set UsrName = New NotesName( doc.FullName(0) ) '取个人文档中用户名,如user/ou2/ou1/ou/o
doc.Level0 = UsrName.OrgUnit1 '取对应的OU,此为ou,赋值为level0
doc.Level1 = UsrName.OrgUnit2
doc.Level2 = UsrName.OrgUnit3
Call doc.Save( False,False ) '保存文档
i = i + 1 'i累加
Set doc = col.GetNextDocument( doc ) '下一份文档
Wend
MessageBox( "完成"+ CStr( i ) +"个文档公司层次调整!")
End Sub
添加新评论9 条评论
2014-11-23 19:00
2014-10-31 12:00
2013-08-06 11:09
2013-05-04 16:26
2013-04-16 14:21
2013-03-13 17:26
2013-03-13 11:04
2013-03-06 09:23
2013-03-05 17:50