dinhienhy
dinhienhy

Reputation: 15

How to add an User Content through Sensenet Client?

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

Please give me a solution.

Thanks so much.

Upvotes: 0

Views: 104

Answers (1)

Miklós Tóth
Miklós Tóth

Reputation: 1511

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.

Upvotes: 1

Related Questions