概述
1 代理
Sub Initialize
On Error Goto ErrHandler
Dim sView As NotesView
Dim sDoc As NotesDocument
Set s = New NotesSession
Set db = s.CurrentDatabase
Dim isExist As String
'Dim Level As Integer
Dim admin(0 To 0) As String'需要添加的帳號信息
admin(0) = "CN=With Wang/OU=CN/O=CMINL" ' "With Wang/CN/CMINL"
'需要添加管理員權限的系統View
Set ApList = db.getView("Vw_ApList")
Set Ap = ApList.GetFirstDocument
While Not(Ap Is Nothing)
If Ap.ServerIp(0) = "10.189.128.3" Then
Set refreshDB = s.GetDatabase(Ap.ServerIp(0),Ap.ApPath(0))
Call refreshDB.sign(DBSIGN_DOC_ALL)
Set acl = refreshDB.ACL
stringArray = acl.roles
Print "Ap:name" & Ap.ServerName(0)
'Level = refreshDB.QueryAccess(session.UserName)
If refreshDB.QueryAccess(s.UserName) <> 6 Then
Print "您不是系統管理員,無權執行此程式!!!!"
'Call SendToMail(Ap.ServerName(0)&"您不是系統管理員,無權執行此程式!!!!")
'Exit Sub
'Set Ap = ApList.GetNextDocument(Ap)
Goto ErrHandler
End If
For j = 0 To Ubound(admin)
Print "admin" & admin(j)
isExist ="N"
Set entry = acl.GetFirstEntry
While Not(entry Is Nothing)
'只更新 Person
If entry.IsPerson And Not(entry.IsGroup) Then
Print entry.Name
'檢查帳號是否存在
If Ucase(entry.Name) = Ucase(admin(j)) Then
isExist ="Y"
End If
End If
Set entry = acl.GetNextEntry(entry)
Wend
If isExist <>"Y" Then
'在ACL中添加新条目:
Set acl = refreshDB.ACL
'这个例子中,我们添加管理员 With Wang/CN/CMINL
Set nEntry = acl.CreateACLEntry(admin(j), 6 )
nEntry.CanDeleteDocuments=True
nEntry.IsPerson=True
'取决于要分配的权限,您可以包含下列可选属性
nEntry.CanCreateSharedFolder=True
nEntry.CanCreatePersonalFolder=True
nEntry.CanCreatePersonalAgent=True
nEntry.CanCreateLSOrJavaAgent=True
For i=0 To Ubound(stringArray)
Call nEntry.EnableRole(stringArray(i))
Next
End If
Next
'保存对ACL的更改
Call acl.Save
Ap.sflag = "Y"
Call Ap.Save(True,True)
End If
Goto ErrHandler
ErrHandler:
Set Ap = ApList.GetNextDocument(Ap)
Wend
Msgbox("OK")
Call SendToMail("OK")
'Msgbox("Error")
'Print "Error"
'Call SendMail("Error")
End Sub
2 SendToMail:
Sub SendToMail(subject As String)
Dim s As New Notessession
Dim maildb As Notesdatabase
Dim db As notesdatabase
Set db=s.CurrentDatabase
Set maildb=s.currentdatabase
Dim maildoc As notesdocument
Set maildoc = New notesdocument(maildb)
Dim rtitem As notesrichtextitem
Set rtitem = New notesrichtextitem(maildoc,"Body")
maildoc.Form. = "memo"
maildoc.Subject = subject
maildoc.cFrom = db.server+"Notes伺服器"
maildoc.From = db.server
maildoc.SendTo = "With Wang/CN/CMINL"
'Call rtitem.AppendDocLink(Doc, doc.FormTitle(0))
Call maildoc.send(False)
End Sub
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24998103/viewspace-700377/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/24998103/viewspace-700377/
最后
以上就是俊秀小松鼠为你收集整理的代碼批量添加ACL管理員權限的全部内容,希望文章能够帮你解决代碼批量添加ACL管理員權限所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复