3

Hello I am new to Active Directory on premise and my problem is to create user using API. I searched about this, but did not found any documentation. One thing i found is AD Connect but by documentation didn't get any clue. Can any one please let me know is this possible or i'm doing any mistake?

5
  • Please add some relevant code, like what you tried and where you failed. Oh, and is this about an on premise AD, or about an Azure AD? You have all kinds of tags going on, so I'm not sure. Commented Dec 19, 2018 at 15:00
  • @rickvdbosch thanks for response. sorry for inconvenience if you didn't got it. this is on premise AD. not Azure AD. i did not found any documentation so not reach at code stage :) Commented Dec 19, 2018 at 15:05
  • Possible duplicate: Creating Active Directory user with password in C# Commented Dec 19, 2018 at 15:20
  • You need to separate this in to multiple pieces. You can't just "create/delete users using API". You need to 1) Create an API project, then 2) Create users in your API code, and 3) delete users in your API code. Commented Dec 19, 2018 at 15:33
  • 1
    @rickvdbosch thanks but please can you answer my already raised question? [stackoverflow.com/questions/53815660/… Commented Dec 20, 2018 at 7:13

1 Answer 1

0

Yes, you can! The link provided by rickvdbosch will get you far.

  1. First, you need to add a using System.DirectoryServices.AccountManagement; statement to your file and possibly a reference to the System.DirectoryServices.AccountManagement assembly.

  2. You can connect to AD using something like this:

    var username = "your username"; var password = "your password"; var domain = "your domain"; var ctx = new PrincipalContext(ContextType.Domain, domain, username, password);

  3. Then perform the operations using the PrincipalContext object. (There's a good example in the link that rickvdbosch gave.)

Sign up to request clarification or add additional context in comments.

1 Comment

@marilee-turscak-msft thanks but can you please answer my question [stackoverflow.com/questions/53815660/… Actually i want to make active directory manager.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.