I am using Sitecore 10.1
, there is a business requirements to allow external system to add CM users to Sitecore so my question is:
- Is there an
API
that we can access to add theusers
in Sitecore?
Creating a custom API will work for you. Where you can write this logic to create user into Sitecore database. Here is a code snippet that you can refer to.
System.Web.Security.Membership.CreateUser(domain\user, "password", "[email protected]");
For example
System.Web.Security.Membership.CreateUser(@"sitecore\myuser", "b", "[email protected]");
Hope this helps.
Sitecore provides RESTful APIs for Item
manipulation but there is NO native API to create user in Sitecore.
You will need custom API for same.
Sitecore uses the standard ASP.NET Membership
provider for its users so you can create users with custom API calls.
userName = string.Format(@"{0}\{1}", domain, userName);
Membership.CreateUser(userName, password, email);
You can create your custom API using this code sample. Programmatically Add/Edit Users
Hope it helps!
In my project, I encountered a similar necessity, wherein an external system required the creation of users within Sitecore. To address this, I developed an API facilitating the seamless creation of users from the external system directly into Sitecore.
This is a code which you can use:
string userNameWithDomain = "extranet\\myuser";
string password = "somepassword";
string email = "[email protected]";
Membership.CreateUser(userNameWithDomain, password, email);