Help in ADSI
-
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
-
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
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