注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

红烧鱼

linux & windows management

 
 
 

日志

 
 
关于我
mac

专注IT基础架构设计与运维。 欢迎给我留言,或邮件沟通zjwsk@163.com

网易考拉推荐

Adding new Windows User Account using Active Directory in VB.NET  

2010-05-19 20:45:24|  分类: Server Managemen |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

http://www.vbdotnetheaven.com/UploadFile/tionescu/AddingnewwindowsuserInVB11112005041553AM/AddingnewwindowsuserInVB.aspx

I used Active Directory to add new user account. The Active Directory will be accessed using windows native protocol (not LDAP).

The code is like following:

'active directory connection string
strConn = AUTHENTICATION_STRING + Environment.MachineName & "," & KEY_COMPUTER
'active directory entry point for above connection string
objAD = New DirectoryEntry(strConn)

where strConn is connection string for native (NT) protocol and objAD is Active Directory entry point.

We will add new user using "Invoke" method which access special windows API functions:

'new user is added
objNewUser = objAD.Children.Add(USER_NAME, "user")
objNewUser.Invoke("SetPassword",
New Object() {USER_PWD})
objNewUser.Invoke("Put",
New Object() {"Description", USER_DESCR})
objNewUser.CommitChanges()

After adding new user in Active Directory we can put this user in a properly group:

'finding group
objGrp = objAD.Children.Find(USER_GROUP, "group")
'adding new user to group
If objGrp.Name <> "" Then
objGrp.Invoke("Add", New Object() {objNewUser.Path.ToString()})
End If 'endif

NOTE: THIS ARTICLE IS CONVERTED FROM C# TO VB.NET USING A CONVERSION TOOL. ORIGINAL ARTICLE CAN BE FOUND ON C# CORNER (
WWW.C-SHARPCORNER.COM).

  评论这张
 
阅读(523)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017