来源:www.cncfan.com | 2006-4-4 | (有1874人读过)
程序代码:
'======================================================= '函数介绍:通过ASP管理NT帐号 '本函数使用ADSI,需要Administrators组用户权限 '==================================================== '填加用户 '函数用法:AddUser(Computer,UserName,PassWord,FullName,Info) '参数:计算机名,帐号名称,帐号密码,帐号全名,帐号说明 '例:AddUser "127.0.0.1","Test","Test","测试管理员帐号","本帐号通过ASP填加" '修改指定用户基本信息 '函数用法:EditUser(Computer,UserName,OldPassWord,PassWord,FullName,Info) '参数:计算机名,帐号名称,帐号密码,帐号全名,帐号说明 '例:EditUser "127.0.0.1","Test","Test2","测试管理员帐号修改","本帐号通过ASP修改过" '删除指定用户 '函数用法:DelUser(Computer,UserName) '参数:计算机名,用户名' '例:DelUser "127.0.0.1","Test" ======================================================== Function AddUser(Computer,UserName,PassWord,FullName,Info) '执行创建帐号命令 Set ComputerObj = GetObject("WinNT://"&Computer) Set NewUser = ComputerObj.Create( "User" , UserName ) NewUser.SetInfo '进行帐号设置 NewUser.SetPassword ( PassWord ) '帐号密码 NewUser.FullName = FullName '帐号全名 NewUser.Description = Info '帐号说明 NewUser.UserFlags = &H10000 '&H20000(使用者下次登入时须变更密码) &H0040(使用者不得变更密码) &H10000(密码永久正确) &H0002(帐户暂时停用) NewUser.SetInfo response.write "帐号"&UserName&"创建成功!" Set ComputerObj=nothing End Function
Function EditUser(Computer,UserName,OldPassWord,PassWord,FullName,Info) '读取用户信息 Set ChangeUserObj = GetObject("WinNT://"&Computer&"/"&UserName&",User") '修改帐号密码 if PassWord<>"" then ChangeUserObj.SetPassword PassWord response.write "帐号密码修改成功!<br>" end if '修改帐号全名 if FullName<>"" then UserFullName = ChangeUserObj.get("FullName") ChangeUserObj.FullName = FullName ChangeUserObj.SetInfo response.write "帐号全名修改成功!<br>" end if '修改帐号说明 if Info<>"" then UserFullName = ChangeUserObj.get("Description") ChangeUserObj.Description = Info ChangeUserObj.SetInfo response.write "帐号说明修改成功!<br>" end if Set ChangeUserObj=nothing End Function
Function DelUser(Computer,UserName) Set DelUserObj = GetObject("WinNT://"&Computer&"/"&UserName) If Err = &H800401E4 Then Response.Write "用户"&UserName&"不存在" Response.End End If Set DelObj = GetObject(DelUserObj.Parent) DelObj.Delete "User", DelUserObj.Name Set DelUserObj = Nothing Set DelObj = Nothing Response.Write "删除成功" End Function
|