Add user
-
Hi how do I add user in windows users and groups with code?
Progress is a process , so value it
This depends on what provider you wish to use. With the LDAP Provider, you perform the following: Imports ActiveDS Dim ObjOU As ActiveDs.IADsOU Dim moNativeIADsObject As IADsUser Dim mstrUsername as string = "NewUserName" Dim mstrOUPath as string = "DC=MyDomain,DC=com" Dim mstrPassword as string = "Asecret1" 'Connect to the Organisation Unit (OU) where the account is to be created using OrgUnit ObjOU = GetObject("LDAP://" & mstrOUPath) 'Create the account moNativeIADsObject = ObjOU.Create("User", "CN=" & mstrUsername) moNativeIADsObject.Put("samAccountName", mstrUsername) moNativeIADsObject.SetInfo() ' Ref: http://www.microsoft.com/technet/scriptcenter/guide/sas\_ads\_zjvb.mspx?mfr=true moNativeIADsObject.SetPassword(mstrPassword) moNativeIADsObject.SetInfo()
-
This depends on what provider you wish to use. With the LDAP Provider, you perform the following: Imports ActiveDS Dim ObjOU As ActiveDs.IADsOU Dim moNativeIADsObject As IADsUser Dim mstrUsername as string = "NewUserName" Dim mstrOUPath as string = "DC=MyDomain,DC=com" Dim mstrPassword as string = "Asecret1" 'Connect to the Organisation Unit (OU) where the account is to be created using OrgUnit ObjOU = GetObject("LDAP://" & mstrOUPath) 'Create the account moNativeIADsObject = ObjOU.Create("User", "CN=" & mstrUsername) moNativeIADsObject.Put("samAccountName", mstrUsername) moNativeIADsObject.SetInfo() ' Ref: http://www.microsoft.com/technet/scriptcenter/guide/sas\_ads\_zjvb.mspx?mfr=true moNativeIADsObject.SetPassword(mstrPassword) moNativeIADsObject.SetInfo()
-
Hi I have used WinNt. It works fine but now I need to add the user via a Web service. I have a web method that attemts to create the user but acess is denied which I expect but I need to side this problem
Progress is a process , so value it
A Web Service runs under an account that doesn't have any rights to the domain to add users. Your web service code has to get the username and password of a domain administrator account so it can use those credentials so it can Impersonate the user adding the account to the domain. Google for "web service impersonation" for all kinds of info, pitfalls, examples, ...
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007