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