lotus notes如何为一个组设置用户类型,创建用户和邮箱?使用 lotusscript
how to set user type for lotus notes for a group, to create user and email account? using lotuscript
NotesRegistration.Mailaclmanager="LocalDomainAdmins"
默认情况下,它总是给我一个混合组
LocalDomainAdmins 组的默认设置方式是[个人组]
我的编码更新
Dim reg As New NotesRegistration
Dim dt As Variant
dt = DateNumber(Year(Today)+1, Month(Today), Day(Today))
reg.RegistrationServer = mailsvr
reg.CreateMailDb = True '
reg.CertifierIDFile = certid
reg.Expiration = dt
reg.IDType = ID_HIERARCHICAL
reg.MinPasswordLength = 1
reg.IsNorthAmerican = True
reg.OrgUnit = OU
reg.RegistrationLog = "log.nsf"
reg.UpdateAddressBook = True
reg.Storeidinaddressbook = false
reg.MailInternetAddress = internetpath
reg.Shortname=doc.SelectMail(0)
reg.Mailowneraccess =2
reg.Mailcreateftindex=True
Print mailfile
Print "pass 1"
Dim acl As NotesACL
Print "pass 1-1"
Dim aclEntry As NotesACLEntry
Print "pass 1-2"
Dim dbUser As NotesDatabase
Print "pass 1-3"
Set dbUser = New NotesDatabase(mailsvr,mailfile) ' mail/person.nsf
Print "pass 1-4"
Set acl = dbUser.aCL
Print "pass 1-5"
Set aclEntry = acl.GetEntry("LocalDomainAdmins")
Print "pass 1-6"
aclentry.Usertype = ACLTYPE_PERSON_GROUP ' cannot used
print "pass 1-7"
call acl.Save()
Print "pass 1-8"
结果在服务器端出现一些错误
[0924:000A-0B88] 17/08/2017 09:59:46 AM HTTP 服务器:代理打印:Mail\yonna
[0924:000A-0B88] 17/08/2017 09:59:46 AM HTTP 服务器:代理打印:传递 1
[0924:000A-0B88] 17/08/2017 09:59:46 AM HTTP 服务器:代理打印:通过 1-1
[0924:000A-0B88] 17/08/2017 09:59:46 AM HTTP 服务器:代理打印:通过 1-2
[0924:000A-0B88] 17/08/2017 09:59:46 AM HTTP 服务器:代理打印:通过 1-3
[0924:000A-0B88] 17/08/2017 09:59:46 AM HTTP 服务器:代理打印:通过 1-4
[0924:000A-0B88] 17/08/2017 09:59:46 AM HTTP 服务器:代理打印:通过 1-5
[0924:000A-0B88] 17/08/2017 09:59:46 AM HTTP 服务器:代理打印:通过 1-6
[0924:000A-0B88] 17/08/2017 09:59:46 AM HTTP 服务器:代理 'Register New User' 错误:未设置对象变量
无法在 NotesRegistration class 中更改 Mailaclmanager 条目的类型。
你可以做两件事:
首先:创建用户后你去获取数据库并更改条目"manually":
Dim dbUser as NotesDatabase
Dim acl as NotesACL
Dim aclEntry as NotesACLEntry
'- do your registration here
Set dbUser = New NotesDatabase( usermailserver, usermailpath )
'- use variables for usermailserver and usermailpath that you use as parameters for registeruser
Set acl = dbUser.acl
Set aclEntry = acl.GetEntry( "LocalDomainAdmins" )
aclEntry.UserType = ACLTYPE_PERSON_GROUP
Call acl.Save()
其次:只需修改您的模板 ACL 以包含具有正确类型和访问级别的 LocalDomainAdmins- 括号中的条目(如 [LocalDomainAdmins] ):在创建数据库时,它会从其模板中复制括号中的所有条目并删除括号。
我更喜欢第一种解决方案,因为它不需要对模板进行操作,而且所有内容都集中在代码中的一个位置。
再说一件事:永远,我再说一遍,永远不要在没有至少一个最小错误处理程序的情况下编写代码。每种编码语言都是如此。 Lotus Script 中的最小错误处理程序如下所示:
On error goto ErrorHandler
'- your code goes here
EndOfRoutine:
Exit sub 'or exit function
ErrorHandler:
Print Err & ", " & Error & " in line " & Erl
Resume EndOfRoutine
NotesRegistration.Mailaclmanager="LocalDomainAdmins"
默认情况下,它总是给我一个混合组
LocalDomainAdmins 组的默认设置方式是[个人组]
我的编码更新
Dim reg As New NotesRegistration
Dim dt As Variant
dt = DateNumber(Year(Today)+1, Month(Today), Day(Today))
reg.RegistrationServer = mailsvr
reg.CreateMailDb = True '
reg.CertifierIDFile = certid
reg.Expiration = dt
reg.IDType = ID_HIERARCHICAL
reg.MinPasswordLength = 1
reg.IsNorthAmerican = True
reg.OrgUnit = OU
reg.RegistrationLog = "log.nsf"
reg.UpdateAddressBook = True
reg.Storeidinaddressbook = false
reg.MailInternetAddress = internetpath
reg.Shortname=doc.SelectMail(0)
reg.Mailowneraccess =2
reg.Mailcreateftindex=True
Print mailfile
Print "pass 1"
Dim acl As NotesACL
Print "pass 1-1"
Dim aclEntry As NotesACLEntry
Print "pass 1-2"
Dim dbUser As NotesDatabase
Print "pass 1-3"
Set dbUser = New NotesDatabase(mailsvr,mailfile) ' mail/person.nsf
Print "pass 1-4"
Set acl = dbUser.aCL
Print "pass 1-5"
Set aclEntry = acl.GetEntry("LocalDomainAdmins")
Print "pass 1-6"
aclentry.Usertype = ACLTYPE_PERSON_GROUP ' cannot used
print "pass 1-7"
call acl.Save()
Print "pass 1-8"
结果在服务器端出现一些错误
[0924:000A-0B88] 17/08/2017 09:59:46 AM HTTP 服务器:代理打印:Mail\yonna
[0924:000A-0B88] 17/08/2017 09:59:46 AM HTTP 服务器:代理打印:传递 1
[0924:000A-0B88] 17/08/2017 09:59:46 AM HTTP 服务器:代理打印:通过 1-1
[0924:000A-0B88] 17/08/2017 09:59:46 AM HTTP 服务器:代理打印:通过 1-2
[0924:000A-0B88] 17/08/2017 09:59:46 AM HTTP 服务器:代理打印:通过 1-3
[0924:000A-0B88] 17/08/2017 09:59:46 AM HTTP 服务器:代理打印:通过 1-4
[0924:000A-0B88] 17/08/2017 09:59:46 AM HTTP 服务器:代理打印:通过 1-5
[0924:000A-0B88] 17/08/2017 09:59:46 AM HTTP 服务器:代理打印:通过 1-6
[0924:000A-0B88] 17/08/2017 09:59:46 AM HTTP 服务器:代理 'Register New User' 错误:未设置对象变量
无法在 NotesRegistration class 中更改 Mailaclmanager 条目的类型。
你可以做两件事:
首先:创建用户后你去获取数据库并更改条目"manually":
Dim dbUser as NotesDatabase
Dim acl as NotesACL
Dim aclEntry as NotesACLEntry
'- do your registration here
Set dbUser = New NotesDatabase( usermailserver, usermailpath )
'- use variables for usermailserver and usermailpath that you use as parameters for registeruser
Set acl = dbUser.acl
Set aclEntry = acl.GetEntry( "LocalDomainAdmins" )
aclEntry.UserType = ACLTYPE_PERSON_GROUP
Call acl.Save()
其次:只需修改您的模板 ACL 以包含具有正确类型和访问级别的 LocalDomainAdmins- 括号中的条目(如 [LocalDomainAdmins] ):在创建数据库时,它会从其模板中复制括号中的所有条目并删除括号。
我更喜欢第一种解决方案,因为它不需要对模板进行操作,而且所有内容都集中在代码中的一个位置。
再说一件事:永远,我再说一遍,永远不要在没有至少一个最小错误处理程序的情况下编写代码。每种编码语言都是如此。 Lotus Script 中的最小错误处理程序如下所示:
On error goto ErrorHandler
'- your code goes here
EndOfRoutine:
Exit sub 'or exit function
ErrorHandler:
Print Err & ", " & Error & " in line " & Erl
Resume EndOfRoutine