知道怎么增加一个用户吗?在windows中,要用.net代码实现

iwebsms 2004-09-13 06:00:14
知道怎么增加一个用户吗?在windows中,要用.net代码实现
...全文
66 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
aycn 2004-09-13
  • 打赏
  • 举报
回复
Private Sub AddUser(ByVal strDoamin As String, ByVal strLogin As String, ByVal strPwd As String)
Dim obDirEnTry As System.DirectoryServices.DirectoryEntry = Nothing
Try
obDirEnTry = New System.DirectoryServices.DirectoryEntry("WinNT://" + strDoamin)
Dim entries As System.DirectoryServices.DirectoryEntries = obDirEnTry.Children
Dim obUser As System.DirectoryServices.DirectoryEntry = entries.Add(strLogin, "User")
obUser.Properties("FullName").Add("Amigo")
Dim obRet As Object = obUser.Invoke("SetPassword", strPwd)
obUser.CommitChanges()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub


记得要在解决方案资源管理器添加 System.DirectoryServices 的引用.
调用例子:
AddUser("YourComputerName", "TestUser", "TestUser")

16,556

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧