使用VBScript及WSH,在windows 2003下创建域帐户及属性
2008-11-05 13:55
323 查看
针对我上一篇提到的问题,我简单做了一个脚本用来自动更改2003系统下的域帐户相关属性。当然代码中有不完善的地方,恳请朋友们提出意见,以便我更好的研究与完善,谢谢大家!代码如下:
On Error Resume Next
Dim userName
Dim userChineseName
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
If Wscript.arguments.count < 1 then
userName=InputBox("Powered By adlinktech.com "&vbCr&vbCr&" 本程序将自动创建用户名 "&vbCr&vbCr&"请(按照邮箱用户名)输入用户名:","Windows server2003帐户自动创建器","adlinkUser")
If userName = "" Then
Wscript.quit
End If
Else
userName = Wscript.arguments.Item(0)
End If
set objDomain = GetObject("LDAP://dc=adlinktech,dc=com")
Set objContainer = GetObject("LDAP://ou=SH,ou=CN,dc=adlinktech,dc=com")
Set objUser = objContainer.Create("User", "cn="&userName)
intUAC = objUser.Get("userAccountControl")
objUser.Put "displayName", "" &userName '显示名
objUser.Put "sAMAccountName", "" &userName '帐户名
objUser.Put "userPrincipalName", userName &"@adlinktech.com" '注册帐户
objUser.Put "mail", userName &"@adlinktech.com" '注册邮箱
objUser.Put "description", "" &userName '描述
objUser.SetPassword "" &username '设置密码
If ADS_UF_DONT_EXPIRE_PASSWD AND intUAC Then '设置密码永不过期
Wscript.echo "Already enabled"
Else
objUser.Put "userAccountControl", intUAC XOR _
ADS_UF_DONT_EXPIRE_PASSWD
objUser.SetInfo
End If
objUser.SetInfo
if err = 0 then
Wscript.echo "OK!请注册用户吧!"
end if
if err <> 0 then
Wscript.echo "error!输入的用户名已经存在。"
Err.Clear
end if
Wscript.echo "OK!一个用户已经创建!"
以上代码我已经在服务器上试过了,可以顺利完成!现在有个问题,“描述”想写上中文,能不能通过inputbox单击确定按钮后,在弹出一个对话框输入相应的描述信息,但是我想了几个办法都不行,希望大家能帮助我想想。
On Error Resume Next
Dim userName
Dim userChineseName
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
If Wscript.arguments.count < 1 then
userName=InputBox("Powered By adlinktech.com "&vbCr&vbCr&" 本程序将自动创建用户名 "&vbCr&vbCr&"请(按照邮箱用户名)输入用户名:","Windows server2003帐户自动创建器","adlinkUser")
If userName = "" Then
Wscript.quit
End If
Else
userName = Wscript.arguments.Item(0)
End If
set objDomain = GetObject("LDAP://dc=adlinktech,dc=com")
Set objContainer = GetObject("LDAP://ou=SH,ou=CN,dc=adlinktech,dc=com")
Set objUser = objContainer.Create("User", "cn="&userName)
intUAC = objUser.Get("userAccountControl")
objUser.Put "displayName", "" &userName '显示名
objUser.Put "sAMAccountName", "" &userName '帐户名
objUser.Put "userPrincipalName", userName &"@adlinktech.com" '注册帐户
objUser.Put "mail", userName &"@adlinktech.com" '注册邮箱
objUser.Put "description", "" &userName '描述
objUser.SetPassword "" &username '设置密码
If ADS_UF_DONT_EXPIRE_PASSWD AND intUAC Then '设置密码永不过期
Wscript.echo "Already enabled"
Else
objUser.Put "userAccountControl", intUAC XOR _
ADS_UF_DONT_EXPIRE_PASSWD
objUser.SetInfo
End If
objUser.SetInfo
if err = 0 then
Wscript.echo "OK!请注册用户吧!"
end if
if err <> 0 then
Wscript.echo "error!输入的用户名已经存在。"
Err.Clear
end if
Wscript.echo "OK!一个用户已经创建!"
以上代码我已经在服务器上试过了,可以顺利完成!现在有个问题,“描述”想写上中文,能不能通过inputbox单击确定按钮后,在弹出一个对话框输入相应的描述信息,但是我想了几个办法都不行,希望大家能帮助我想想。
相关文章推荐
- 通过outlook connector使用Outlook 2003 或 Outlook 2007 访问和管理 Windows Live Hotmail 或 Office Live Mail 帐户、联系人,收发送电子邮件
- 原创翻译 使用Windows Embedded Standard创建电池供电的设备(一)
- SharePoint 创建列表并使用Windows Presentation Foundation应用程序管理列表
- linux下使用RIS网络批量布署windows 2003
- windows 2003为什么不能使用移动硬盘
- android:windowSoftInputMode属性使用
- 如何让CloudStack使用KVM创建Windows实例成功识别并挂载数据盘
- 使用指令创建自定义属性的Angular JS
- Windows Server 2003 创建和管理用户帐户
- android:windowSoftInputMode属性使用心得
- 在AndroidManifest.xml文件中的android:windowSoftInputMode属性使用
- 【Oracle】教你一步一步在Windows 8.1系统下使用使用"Database Configuration Assistant"(Oracle 12c)创建数据库
- 【Windows编程】系列第七篇:Menubar的创建和使用
- VC中Windows常用控件的创建和使用
- windows下使用sc创建服务 配置自动启动
- Linux于Windows使用Samba共享文件时文件属性nobody nogroup的解决办法
- 利用windows service 2003来创建操作主机与活动目录数据库的维护的架设与维护
- 在windows上使用symfony创建简易的CMS系统(一)
- 跟我一起学Windows Workflow Foundation(5)-----使用activity设计器创建一个整合的定制activity(转)
- 在windows上使用symfony创建简易的CMS系统(三)