How to add an User Content through Sensenet Client?

109 views Asked by At

I want to add an User Content of Sensenet from a client which developed by .NET.

Please give me a solution.

Thanks so much.

1

There are 1 answers

1
Miklós Tóth On BEST ANSWER

You should be able to create users the same way as any other content, by providing the parent, the content type name and a few mandatory fields.

The example below assumes that you already initialized the client, you have the /Root/IMS/MyDomain/MyOrgUnit in your repo and there is no existing user there with the same name.

var user = Content.CreateNew("/Root/IMS/MyDomain/MyOrgUnit", "User", "johnsmith");
user["LoginName"] = "johnsmith"; // best practice: same as the content name in the line above
user["Password"] = "123456789";
user["FullName"] = "John Smith";
user["Email"] = "[email protected]"; // this has to be unique under the domain
user["Enabled"] = true; // to let the user actually log in
await user.SaveAsync();

Let us know if you encounter any errors.