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?
-
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.rickvdbosch– rickvdbosch2018-12-19 15:00:55 +00:00Commented 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 :)sakulachi8– sakulachi82018-12-19 15:05:23 +00:00Commented Dec 19, 2018 at 15:05
-
Possible duplicate: Creating Active Directory user with password in C#rickvdbosch– rickvdbosch2018-12-19 15:20:25 +00:00Commented 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.Gabriel Luci– Gabriel Luci2018-12-19 15:33:44 +00:00Commented Dec 19, 2018 at 15:33
-
1@rickvdbosch thanks but please can you answer my already raised question? [stackoverflow.com/questions/53815660/…sakulachi8– sakulachi82018-12-20 07:13:29 +00:00Commented Dec 20, 2018 at 7:13
1 Answer
Yes, you can! The link provided by rickvdbosch will get you far.
First, you need to add a
using System.DirectoryServices.AccountManagement;statement to your file and possibly a reference to theSystem.DirectoryServices.AccountManagementassembly.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);
Then perform the operations using the PrincipalContext object. (There's a good example in the link that rickvdbosch gave.)