宇山
作者宇山·2015-01-14 17:30
其它·失业中。。。

一个简单代理,批量处理用户公司层次结构

字数 1120阅读 837评论 0赞 0
当注册用户用户名格式为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
 

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

0

添加新评论0 条评论

Ctrl+Enter 发表

作者其他文章

相关文章

相关问题

相关资料

X社区推广