新用户注册代码

1、用户登录:
你用模板库(domcfg5.ntf)来生成一个库(domcfg.nsf)
然后修改中的一个表单($$LoginUserForm)
2
、新用户注册代码供你参考:
'
定义在代理中将要用到的对象
Dim session As New NotesSession '
定义服务器Session变量,一个用户一个线程
Dim db As NotesDatabase '
定义一个Notes数据库对象
Dim dbn As notesdatabase
Dim acl As NotesACL '
定义一个Notes数据库的存取控制列表对象
Dim entry As NotesACLEntry '
定义一个Notes数据库的存取控制列表内的条目对象
Dim view As NotesView '
定义一个Notes数据库内的视图对象
Dim doc As NotesDocument '
定义一个Notes数据库内的文档对象
'
邮件信息
Dim MailDb As NotesDatabase
Dim CopyMailDB As Notesdatabase
Dim template AsNotesDatabase

Dim MailACL As NotesACL
Dim MailEntry As NotesACLEntry

Dim fileName As String

Dim cgi As NotesDocument
Set cgi = session.DocumentContext

'
如果帐号为空,则提示
If (cgi.LastName(0)=""<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><shapetype id="_x0000_t75" stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"><stroke joinstyle="miter"></stroke><formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f></formulas><path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></path><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><lock aspectratio="t" v:ext="edit"></lock></shapetype><shape id="_x0000_i1025" style="WIDTH: 12.75pt; HEIGHT: 12.75pt" type="#_x0000_t75" alt=""><imagedata o:href="http://www.chinalotus.com/wyf/images/smilies/wink.gif" src="file:///C:%5CDOCUME~1%5CADMINI~1%5CLOCALS~1%5CTemp%5Cmsohtml1%5C01%5Cclip_image001.gif"></imagedata></shape>Then
Msgbox cgi.referer(0)
Print "<font size=2>
用户帐号录入了空值,不能注册</font>"
Print "<hr size=1 color=red>"
Print "
点击这里<a href='javascript:history.back(0);'><font size=2>返回</font></a>"
Exit Sub
Else
Dim letterCode As Long
Dim ln As String
Dim l As Long

ln =cgi.lastName(0)
l =Len(cgi.lastName(0))
For i = 1 To l
letterCode =Asc(Lcase(Mid(ln,i,1)))
If letterCode<Asc("a") Or (letterCode>Asc("z"))Then
If letterCode<Asc("0") Or letterCode>Asc("9") Then
Print "<font size = 2 >
用户帐号包含非法字符"
Print "<hr size=1 color=red>"
Print "
点击这里<a href='javascript:history.back(0);'><font size=2>返回</font></a>"
Exit Sub
End If
End If
Next
End If

'
如果用户密码为空,则提示
If (cgi.HTTPPassword(0)="") Then
Print "<font size=2>
您的密码没有得到确认,不能注册</font>"
Print "<hr size=1 color=red>"
Print "
点击这里<a href='javascript:history.back();'><font size=2>返回</font></a>"
Exit Sub
End If
'
如果确认密码为空,则提示
If (cgi.Password(0)="") Then
Print "<font size=2>
确认密码录入了空值,不能注册</font>"
Print "<hr size=1 color=red>"
Print "
点击这里<a href='javascript:history.back();'><font size=2>返回</font></a>"
Exit Sub
End If
'
如果真实姓名为空,则提示
If (cgi.PeopleName(0)="") Then
Print "<font size=2>
真实姓名录入了空值,不能注册</font>"
Print "<hr size=1 color=red>"
Print "
点击这里<a href='javascript:history.back();'><font size=2>返回</font></a>"
Exit Sub
End If

Set db = session.GetDatabase("", "names.nsf") '
db指向Domino目录
Set view = db.GetView("People") '
Domino目录的People视图
Set doc = view.GetDocumentByKey(cgi.LastName(0), True) '
得到帐号名为LastName域值的用户文档
If Not(doc Is Nothing) Then '
如果已经有相同的帐号存在,那么提示
Print "<font size=2>
用户帐号为: "+cgi.LastName(0)+" 的用户已经存在了,不能注册</font>"
Print "<hr size=1 color=red>"
Print "
点击这里<a href='javascript:history.back();'><font size=2>返回</font></a>"
Exit Sub
End If

If (cgi.user(0)="webadmini") Or (cgi.user(0)="KMHWAdmin") Or (cgi.user(0)="developer") Then
Set doc = db.CreateDocument() '
Domino目录内创建一个新文档doc
doc.Form = "Person" '
填写doc的域 Form (一个隐藏域)
doc.Type = "Person" '
填写doc的域 Type
doc.LastName = cgi.LastName(0) '
填写doc的域 FullName
doc.FullName = cgi.LastName(0) '
填写doc的域 LastName
doc.HTTPPassword = cgi.HTTPPassword(0)'
填写doc的域 HTTPPassord
doc.Password = cgi.Password(0) '
填写doc的域 Passord
doc.PeopleName = cgi.PeopleName(0) '
填写doc的域 PeopleN ame
doc.MailSystem = "6"
doc.MailServer = session.userName
doc.MailFile = Trim("mail/"+cgi.lastName(0))
doc.MailDomain = cgi.doMain(0)

Call doc.Save(True, False) '
保存 doc

Set acl = db.ACL '
提取Domino目录的存取控制列表
Set entry = acl.CreateACLEntry(cgi.LastName(0), ACLLEVEL_MANAGER)'
添加注册用户到存取控制列表里面,并设置其为管理员]
entry.CanDeleteDocuments = False '
不能删除文档
Call acl.Save() '
保存修改结果到Domino目录
Set db = session.CurrentDatabase '
db指向当前数据库
Set acl = db.ACL '
提取当前数据库的存取控制列表
Set entry = acl.CreateACLEntry(cgi.LastName(0), ACLLEVEL_MANAGER)'
添加条目到当前数据库的存取控制列表之中
entry.CanDeleteDocuments = False
Call acl.Save() '
保存结果
'
创建邮件数据库
Set mailDb = New notesDatabase("","mail.nsf")'
邮件系统模板
fileName = Trim("mail\"+cgi.lastName(0)+".nsf")'
目标邮件数据库文件名
Set CopyMailDB =MailDB.CreateCopy("",fileName)'
邮件数据库(个人)
CopyMailDB.Title =cgi.PeopleName(0)+"
个人邮箱"'邮件数据库标题
Set MailACL = CopyMailDB.ACL
Set MailEntry =MailACL.CreateACLEntry(cgi.lastName(0),ACLLEVEL_MANAGER)
CallMailACL.save
'Set MailEntry =MailACL.CreateACLEntry(cgi.user(0),ACLLEVEL_MANAGER)
'CallMailACL.save
Print "<font size=2>
用户帐号"+cgi.LastName(0)+" 已经注册成功了</font>"
Print "
且已经创建"+cgi.peopleName(0)+"个人邮箱("+copyMailDB.FileName+")"
Print "<hr size=1 color=red>"
Print "
点击这里<a href='javascript:history.back();'><font size=2>返回</font></a>"

Else
Print "<font size=2>
您不是系统管理员,不能注册</font>"
Print "<hr size=1 color=red>"
Print "
点击这里<a href='javascript:history.back();'><font size=2>返回</font></a>"
End If

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值