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. Urgent Regarding Directoryentry.Invoke(Setpassword,"") method

Urgent Regarding Directoryentry.Invoke(Setpassword,"") method

Scheduled Pinned Locked Moved C#
sysadminhelpdata-structuresdebugging
5 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.
  • S Offline
    S Offline
    shambho
    wrote on last edited by
    #1

    I have a very typical problem. I am trying to create a user in activedirectory running in windows 2003 server. i am able to create user but when coming to setting password its not working. the code : String strPath = "LDAP://192.168.0.101:389/OU=100001,DC=Tserver,DC=local"; try { DirectoryEntry user = new DirectoryEntry(strPath, @"Tserver.local\administrator", "password", AuthenticationTypes.Secure | AuthenticationTypes.Sealing |AuthenticationTypes.ServerBind ); //create user DirectoryEntry user = entry.Children.Add("cn=Test User", "user"); user.Properties["sAMAccountName"].Add("testuser"); user.Properties["sn"].Add("User"); user.Properties["givenName"].Add("Test"); user.Properties["description"].Add("Test account added with code."); user.CommitChanges(); // User has to be saved prior to this step user.Invoke("SetPassword", new string[] {"password1"} ); user.CommitChanges(); user.Close(); user.Dispose(); } catch (Exception exx) { Response.Write("Exception: "+ exx.ToString() + " \n"); return; } Response.Write("Success: Password set."); Error Description: Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO.FileNotFoundException: The network path was not found. Source Error: Line 127: Line 128: // User has to be saved prior to this step Line 129: user.Invoke("SetPassword", new string[] {"princeton"} ); Line 130: user.Properties["userAccountControl"].Value = 0x200; Line 131: user.CommitChanges(); Source File: c:\inetpub\wwwroot\adminlogin\pages\information.aspx.cs Line: 129 Stack Trace: [FileNotFoundException: The network path was not found.] [TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0 System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) +473 System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args) +29 System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args) AdminLogin.Information.btnSave_Click(Object sender, EventArg

    L N 2 Replies Last reply
    0
    • S shambho

      I have a very typical problem. I am trying to create a user in activedirectory running in windows 2003 server. i am able to create user but when coming to setting password its not working. the code : String strPath = "LDAP://192.168.0.101:389/OU=100001,DC=Tserver,DC=local"; try { DirectoryEntry user = new DirectoryEntry(strPath, @"Tserver.local\administrator", "password", AuthenticationTypes.Secure | AuthenticationTypes.Sealing |AuthenticationTypes.ServerBind ); //create user DirectoryEntry user = entry.Children.Add("cn=Test User", "user"); user.Properties["sAMAccountName"].Add("testuser"); user.Properties["sn"].Add("User"); user.Properties["givenName"].Add("Test"); user.Properties["description"].Add("Test account added with code."); user.CommitChanges(); // User has to be saved prior to this step user.Invoke("SetPassword", new string[] {"password1"} ); user.CommitChanges(); user.Close(); user.Dispose(); } catch (Exception exx) { Response.Write("Exception: "+ exx.ToString() + " \n"); return; } Response.Write("Success: Password set."); Error Description: Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO.FileNotFoundException: The network path was not found. Source Error: Line 127: Line 128: // User has to be saved prior to this step Line 129: user.Invoke("SetPassword", new string[] {"princeton"} ); Line 130: user.Properties["userAccountControl"].Value = 0x200; Line 131: user.CommitChanges(); Source File: c:\inetpub\wwwroot\adminlogin\pages\information.aspx.cs Line: 129 Stack Trace: [FileNotFoundException: The network path was not found.] [TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0 System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) +473 System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args) +29 System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args) AdminLogin.Information.btnSave_Click(Object sender, EventArg

      L Offline
      L Offline
      LongRange Shooter
      wrote on last edited by
      #2

      99% of the time....when you get a System.Exception.FileNotFound it is due to the fact that you are trying to get an assembly and that assembly either does not exist on the target machine ... or it does exist but the assembly identifiers do not match. For example: if you built your application and used System.Security.dll which had an assembly identifier of version 1.1.4322 but a service pack that your machine did not receive had version System.Security.dll at version 1.1.4325 then you would get that exception. This signature left intentionally blank

      S 1 Reply Last reply
      0
      • S shambho

        I have a very typical problem. I am trying to create a user in activedirectory running in windows 2003 server. i am able to create user but when coming to setting password its not working. the code : String strPath = "LDAP://192.168.0.101:389/OU=100001,DC=Tserver,DC=local"; try { DirectoryEntry user = new DirectoryEntry(strPath, @"Tserver.local\administrator", "password", AuthenticationTypes.Secure | AuthenticationTypes.Sealing |AuthenticationTypes.ServerBind ); //create user DirectoryEntry user = entry.Children.Add("cn=Test User", "user"); user.Properties["sAMAccountName"].Add("testuser"); user.Properties["sn"].Add("User"); user.Properties["givenName"].Add("Test"); user.Properties["description"].Add("Test account added with code."); user.CommitChanges(); // User has to be saved prior to this step user.Invoke("SetPassword", new string[] {"password1"} ); user.CommitChanges(); user.Close(); user.Dispose(); } catch (Exception exx) { Response.Write("Exception: "+ exx.ToString() + " \n"); return; } Response.Write("Success: Password set."); Error Description: Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO.FileNotFoundException: The network path was not found. Source Error: Line 127: Line 128: // User has to be saved prior to this step Line 129: user.Invoke("SetPassword", new string[] {"princeton"} ); Line 130: user.Properties["userAccountControl"].Value = 0x200; Line 131: user.CommitChanges(); Source File: c:\inetpub\wwwroot\adminlogin\pages\information.aspx.cs Line: 129 Stack Trace: [FileNotFoundException: The network path was not found.] [TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0 System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) +473 System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args) +29 System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args) AdminLogin.Information.btnSave_Click(Object sender, EventArg

        N Offline
        N Offline
        Nick Parker
        wrote on last edited by
        #3

        shambho wrote: // User has to be saved prior to this step user.Invoke("SetPassword", new string[] {"password1"} ); Your should be passing an Object[] instead:

        Object[] pswd = new Object[]{"password1"};

        However by default all code that executes from the local intranet or Internet zones is partially trusted and full trust is required. You might check into placing the AllowPartiallyTrustedCallers attribute on your code. - Nick Parker
        My Blog | My Articles

        S 1 Reply Last reply
        0
        • L LongRange Shooter

          99% of the time....when you get a System.Exception.FileNotFound it is due to the fact that you are trying to get an assembly and that assembly either does not exist on the target machine ... or it does exist but the assembly identifiers do not match. For example: if you built your application and used System.Security.dll which had an assembly identifier of version 1.1.4322 but a service pack that your machine did not receive had version System.Security.dll at version 1.1.4325 then you would get that exception. This signature left intentionally blank

          S Offline
          S Offline
          shambho
          wrote on last edited by
          #4

          But my dear friend i am able to create user add all other properties why not password. Is this System.Security.dll has some thing to do with setpassword native method alone. I dont know thats why i am posting this reply. Kindly reply me thanks in advance anand

          1 Reply Last reply
          0
          • N Nick Parker

            shambho wrote: // User has to be saved prior to this step user.Invoke("SetPassword", new string[] {"password1"} ); Your should be passing an Object[] instead:

            Object[] pswd = new Object[]{"password1"};

            However by default all code that executes from the local intranet or Internet zones is partially trusted and full trust is required. You might check into placing the AllowPartiallyTrustedCallers attribute on your code. - Nick Parker
            My Blog | My Articles

            S Offline
            S Offline
            shambho
            wrote on last edited by
            #5

            hi friend, actually i am not using user.Invoke("SetPassword", new string[] {"password1"} ); but user.Invoke("SetPassword", new object[] {"password1"} ); By mistake while i was trying different alternative you got this piece of code. even with object its giving the same error

            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