none
C# code for object movement in cross domain. RRS feed

  • Question

  • I have two domain under same forest & I want to move user from one domain to another domain using c# code. With the below code I am getting error while moving users in different domain(under same domain it is working).

           DirectoryEntry eLocation = new DirectoryEntry(url, user, pass, AuthenticationTypes.ServerBind);
           DirectoryEntry nLocation = new DirectoryEntry(url1, user1, pass1, AuthenticationTypes.ServerBind);
           eLocation.MoveTo(nLocation);
           nLocation.Close();
           eLocation.Close();

    error for the cross domain movement is ::

    {"The user name or password is incorrect.\r\n"}

    Wednesday, February 13, 2019 7:06 AM

All replies

  • Hi Premchand

    Thank you for posting here.

    According to your description, you want to move the user from one domain to another domain.

    Based on my search, the following link could help you.

    https://docs.microsoft.com/en-us/previous-versions/tn-archive/ee198798(v=technet.10)

    Hope my advice could be helpful.

    Best regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.



    Thursday, February 14, 2019 8:13 AM
    Moderator
  • Hello Jack, 

    The method pointed in the answer is causing the problem. There is no built-in method 'Set' and 'GetObject' in c#, 

    so the code is not getting compiled, please suggest if any alternate way I can use it.

    Thanks :

    Premchand.

    Thursday, February 14, 2019 10:57 AM
  • Hi Premchand <g class="gr_ gr_20 gr-alert gr_spell gr_inline_cards gr_disable_anim_appear ContextualSpelling ins-del multiReplace" data-gr-id="20" id="20">singh</g>,

    Thanks for the feedback.

    The user name or password is incorrect.\r\n

    According to your error, it is best for you to check if the username or password is right.

    We could not test your code due to the lack of multiple domain names.

    Hope my advice could be helpful.

    Best Regards,

    Jack.



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.



    Wednesday, February 20, 2019 9:03 AM
    Moderator
  • Hello Jack,

    I am using only two domain controllers(in same domain) first one is Parent domain dc(source domain) and the second one is the destination dc where I want to move the user. I have added the parent domain username(through which I am logging in) in the administrator group of the destination domain machine, how ever I am getting different error this time as ::

    {"Inappropriate authentication.\r\n"}
    I have checked the username/password and It is correct one.

    any suggestions/help would be great !!
    Thanks:

    Premchand


    Thursday, February 21, 2019 9:21 AM
  • Hi  Premchhand <g class="gr_ gr_20 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="20" id="20">singh</g>,

    According to your new error, the reason may be the same as the following link, you could refer to it.

    https://www.openldap.org/lists/openldap-software/200409/msg00244.html

    Note: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as a convenience to you.

    Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.

    There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Best Regards,

    Jack.




    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Thursday, February 21, 2019 9:36 AM
    Moderator
  • Hello Jack, 

    This resolution provided is for the Mac Os, where I am using windows OS, also more over solution in the pointed link is when user is moving the object through command line, but in my case I am moving user through c# code and UI. I think the current issue is somewhere related to user permission but i am not getting the exact permission which requires for this.

    Thursday, February 21, 2019 10:07 AM
  • Hello, I have got some clue from here,
    https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea

    I need to use below LDAP Controller some where in the move operation.

    LDAP_SERVER_CROSSDOM_MOVE_TARGET_OID

    1.2.840.113556.1.4.521

    now I am trying to find out how to use this for the cross domain move in my c# or anywhere.

    Tuesday, February 26, 2019 1:28 PM
  • Hi 

    The code in the following link is similar to the code you provided. It is best for you to read the following link.

    https://stackoverflow.com/questions/35909780/moving-an-ad-user-from-an-ou-to-another-ou

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 1, 2019 7:31 AM
    Moderator