Lotus 脚本锁定用户

Lotus script Lockout users

Sub Initialize

On Error GoTo e
Dim session As New NotesSession, db As NotesDatabase, view As NotesView
Dim nvec As NotesViewEntryCollection
Dim c As integer
Set db = session.currentdatabase

Set view = db.getView("Locked Out Users")
Set nvec = view.Allentries

c = nvec.count

If c > 0 Then

Call nvec.Removeall(true)

' Send notification
Dim sarr(1) As String
sarr(0) = "john.doe@acme.com"
sarr(1) = "foo@acme.com"

Dim mdoc As NotesDocument, rt As notesrichtextitem
Set mdoc = db.createdocument
mdoc.Form = "Memo"
mdoc.Subject = "Removed " + CStr(c) + " Locked out users on mypage"
Set rt = mdoc.Createrichtextitem("Body")
Call rt.Appendtext("Removed " + CStr(c) + " Locked out users")
Call rt.Addnewline(1) 
Call rt.Appendtext("Click to open lockout database")
Call rt.Appenddoclink(db,"Lockout")
Call mdoc.Send(False, sarr)

End If
Exit Sub
e:
Print Error,erl
End Sub

我是 Lotus Domino 的初学者,我有一些问题,是否可以更改此脚本以仅删除具有指定名称的锁定用户?

我添加了类似的内容:

 Dim nam As NotesName
Dim c As integer
Set db = session.currentdatabase
Set nam.OrgUnit1 = (“GD”)
Set view = db.getView("Locked Out Users")
Set nvec.OrgUnit1 = view.Allentries

c = nvec.count

If c > 0 Then

在我的例子中,我需要删除所有指定 dc 的组成员,例如 Robert Kowalski/GD/Company 每个人的名字中都有 dc=GD?

至少有两种方法可以实现您的要求。 首先,您可以复制视图 "Locked Out Users" 并将选择公式更改为仅包含您的 OU。
另一个选项类似于

dim doc as notesdocument
dim nextDoc as notesdocument

set doc = view.getfirstdocument()
while not doc is nothing
 set nextDoc = view.getnextDocument(doc)
 set nam = new notesname(doc.getItemValue("[NAMEITEM]")(0))
 if strcompare(nam.orgUnit1,"GD",5)=0 then
  call doc.remove(true,false)
 end if
set doc = nextDoc 
wend
    Sub Initialize

On Error GoTo e
Dim session As New NotesSession, db As NotesDatabase, view As NotesView
Dim nvec As NotesViewEntryCollection
Dim c As integer
Set db = session.currentdatabase
dim doc as notesdocument
dim nextDoc as notesdocument

set doc = view.getfirstdocument()
while not doc is nothing
 set nextDoc = view.getnextDocument(doc)
 set nam = new notesname(doc.getItemValue("[NAMEITEM]")(0))
 if strcompare(nam.orgUnit1,"GD",5)=0 then
  call doc.remove(true,false)
 end if
set doc = nextDoc 
wend

Set view = db.getView("Locked Out Users")
Set nvec = view.Allentries

c = nvec.count

If c > 0 Then

Call nvec.Removeall(true)

' Send notification
Dim sarr(1) As String
sarr(0) = "john.doe@acme.com"
sarr(1) = "foo@acme.com"

Dim mdoc As NotesDocument, rt As notesrichtextitem
Set mdoc = db.createdocument
mdoc.Form = "Memo"
mdoc.Subject = "Removed " + CStr(c) + " Locked out users on mypage"
Set rt = mdoc.Createrichtextitem("Body")
Call rt.Appendtext("Removed " + CStr(c) + " Locked out users")
Call rt.Addnewline(1) 
Call rt.Appendtext("Click to open lockout database")
Call rt.Appenddoclink(db,"Lockout")
Call mdoc.Send(False, sarr)

End If
Exit Sub
e:
Print Error,erl
End Sub

谢谢@umeli 的回复。我想现在 它应该工作。