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. C#
  4. Help in ADSI

Help in ADSI

Scheduled Pinned Locked Moved C#
helpcsharphtmlcomsysadmin
2 Posts 2 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.
  • J Offline
    J Offline
    jacal99
    wrote on last edited by
    #1

    Hi i am working with ADSI with win 2003 server in c# ... i am trying to make a user the member of a group named "Administrators" ... my user is in an ou named "test2" ... when i start the program ... in the end when it should add the user in Admiistrators group it give me this error "System.Runtime.InteropServices.COMException(0x8004005): Unspecified error" my code is as under... it is on a button click. private void button5_Click(object sender, System.EventArgs e) { try { DirectoryEntry dom = new DirectoryEntry("LDAP://CN=Builtin,DC=jacal99,DC=com"); DirectoryEntry group = dom.Children.Find("CN=Administrators"); MessageBox.Show("group found"); DirectoryEntry dom2 = new DirectoryEntry("LDAP://OU=test2,DC=jacal99,DC=com"); DirectoryEntry usr = dom2.Children.Find("CN=lucky"); MessageBox.Show("user found"); group.Properties["Member"].Add(new string[] {"lucky"}); group.CommitChanges(); MessageBox.Show("user added :)"); } catch (Exception ex) { MessageBox.Show("error coz " + ex); } } ok waiting for the answer ... seea TC bye. Mazhar Hussain

    H 1 Reply Last reply
    0
    • J jacal99

      Hi i am working with ADSI with win 2003 server in c# ... i am trying to make a user the member of a group named "Administrators" ... my user is in an ou named "test2" ... when i start the program ... in the end when it should add the user in Admiistrators group it give me this error "System.Runtime.InteropServices.COMException(0x8004005): Unspecified error" my code is as under... it is on a button click. private void button5_Click(object sender, System.EventArgs e) { try { DirectoryEntry dom = new DirectoryEntry("LDAP://CN=Builtin,DC=jacal99,DC=com"); DirectoryEntry group = dom.Children.Find("CN=Administrators"); MessageBox.Show("group found"); DirectoryEntry dom2 = new DirectoryEntry("LDAP://OU=test2,DC=jacal99,DC=com"); DirectoryEntry usr = dom2.Children.Find("CN=lucky"); MessageBox.Show("user found"); group.Properties["Member"].Add(new string[] {"lucky"}); group.CommitChanges(); MessageBox.Show("user added :)"); } catch (Exception ex) { MessageBox.Show("error coz " + ex); } } ok waiting for the answer ... seea TC bye. Mazhar Hussain

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Using MessageBox.Show is a poor way of debugging. Insert a breakpoint into your code and step through it. On what line does the exception occur? Even just running your code in the debugger (Visual Studio .NET or cordbg.exe) with the necessary symbols (built by default for the Debug project settings) will tell you. That information will be helpful to help you solve your problem.

      Software Design Engineer Developer Division Sustained Engineering, Microsoft My Articles

      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