Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Add user

Add user

Scheduled Pinned Locked Moved Visual Basic
question
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BLOEDHOND
    wrote on last edited by
    #1

    Hi how do I add user in windows users and groups with code?

    Progress is a process , so value it

    V 1 Reply Last reply
    0
    • B BLOEDHOND

      Hi how do I add user in windows users and groups with code?

      Progress is a process , so value it

      V Offline
      V Offline
      Vader_Oz
      wrote on last edited by
      #2

      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()

      B 1 Reply Last reply
      0
      • V Vader_Oz

        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()

        B Offline
        B Offline
        BLOEDHOND
        wrote on last edited by
        #3

        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

        D 1 Reply Last reply
        0
        • B BLOEDHOND

          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

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups