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. "There is no such object on the server" Error after Active Directory SetPasword call

"There is no such object on the server" Error after Active Directory SetPasword call

Scheduled Pinned Locked Moved C#
comsysadminwindows-admindata-structuresdebugging
3 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.
  • H Offline
    H Offline
    Hesham Amin
    wrote on last edited by
    #1

    Hello I use this code to create users in active directory, and set their passwords: static void Main(string[] args) { DirectoryEntry parent = new DirectoryEntry("LDAP://test/OU=Admins,DC=test,DC=org"); Console.WriteLine("OU: "+parent.Name); Console.WriteLine("Domain name:" + System.DirectoryServices.ActiveDirectory.Domain.GetCurrentDomain().Name); string test = "testuser"; for (int i = 0; i < 20; i++) { try { DirectoryEntry child = parent.Children.Add("CN=" + test + i.ToString(), "User"); Console.WriteLine(test + i.ToString() + ": create object"); child.Properties["name"].Value = test + i.ToString(); child.Properties["displayName"].Value = test + i.ToString(); //child.Properties["userPrincipalName"].Value = test + i.ToString() + "@" + System.DirectoryServices.ActiveDirectory.Domain.GetCurrentDomain().Name; child.Properties["GivenName"].Value = test + i.ToString(); child.Properties["Initials"].Value = "q"; child.Properties["sn"].Value = test + i.ToString(); child.Properties["sAMAccountName"].Value = test + i.ToString(); child.CommitChanges(); Console.WriteLine(test + i.ToString() + ": commit info"); child.Invoke("SetPassword", new object[] { "!qwe@ASD" }); child.CommitChanges(); Console.WriteLine(test + i.ToString() + ": commit passowrd"); } catch (Exception ex) { Console.WriteLine(test + i.ToString() + ":"+ ex.ToString()); } } } Within the loop, some users are created and their passwords set successfully, and randomly setting password for some users fail with this error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.DirectoryServices.DirectoryServicesCOMException (0x80072030): There is no such object on the server. (Exception from HRESULT: 0x80072030) --- End of inner exception stack trace --- at System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args) What are the possible causes for this error? and what are the workarounds?

    Hesham A. Amin My blog

    F 1 Reply Last reply
    0
    • H Hesham Amin

      Hello I use this code to create users in active directory, and set their passwords: static void Main(string[] args) { DirectoryEntry parent = new DirectoryEntry("LDAP://test/OU=Admins,DC=test,DC=org"); Console.WriteLine("OU: "+parent.Name); Console.WriteLine("Domain name:" + System.DirectoryServices.ActiveDirectory.Domain.GetCurrentDomain().Name); string test = "testuser"; for (int i = 0; i < 20; i++) { try { DirectoryEntry child = parent.Children.Add("CN=" + test + i.ToString(), "User"); Console.WriteLine(test + i.ToString() + ": create object"); child.Properties["name"].Value = test + i.ToString(); child.Properties["displayName"].Value = test + i.ToString(); //child.Properties["userPrincipalName"].Value = test + i.ToString() + "@" + System.DirectoryServices.ActiveDirectory.Domain.GetCurrentDomain().Name; child.Properties["GivenName"].Value = test + i.ToString(); child.Properties["Initials"].Value = "q"; child.Properties["sn"].Value = test + i.ToString(); child.Properties["sAMAccountName"].Value = test + i.ToString(); child.CommitChanges(); Console.WriteLine(test + i.ToString() + ": commit info"); child.Invoke("SetPassword", new object[] { "!qwe@ASD" }); child.CommitChanges(); Console.WriteLine(test + i.ToString() + ": commit passowrd"); } catch (Exception ex) { Console.WriteLine(test + i.ToString() + ":"+ ex.ToString()); } } } Within the loop, some users are created and their passwords set successfully, and randomly setting password for some users fail with this error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.DirectoryServices.DirectoryServicesCOMException (0x80072030): There is no such object on the server. (Exception from HRESULT: 0x80072030) --- End of inner exception stack trace --- at System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args) What are the possible causes for this error? and what are the workarounds?

      Hesham A. Amin My blog

      F Offline
      F Offline
      foluis
      wrote on last edited by
      #2

      Any luck?

      Luis Fernando Forero G.

      H 1 Reply Last reply
      0
      • F foluis

        Any luck?

        Luis Fernando Forero G.

        H Offline
        H Offline
        Hesham Amin
        wrote on last edited by
        #3

        We have solved the issue long time ago, so I don't remember the issue accurately. But as I remember, it was related to replication. There were multiple domain controllers serving the domain. If first CommitChanges saves data to dc1, the second may go to dc2. The solution is to add users in batch and replicate the domain controllers then update the password in another cycle.

        Hesham A. Amin My blog twitter: @HeshamAmin

        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