# How set a password for the user in c# SDK

**URL:** <https://devforum.okta.com/t/how-set-a-password-for-the-user-in-c-sdk/10360>\
**Category:** Questions\
**Created:** [August 3, 2020, 12:53pm UTC](https://devforum.okta.com/t/how-set-a-password-for-the-user-in-c-sdk/10360 "2020-08-03T12:53:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![praveen](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@praveen](https://devforum.okta.com/u/praveen)\
**Post date:** [August 3, 2020, 12:53pm UTC](https://devforum.okta.com/t/how-set-a-password-for-the-user-in-c-sdk/10360/1 "2020-08-03T12:53:10Z")

</div>

Hi,  
How to set a password for the user, were to select 2 options 1)set by the user and 2)set by admin  
am using okta c#sdk.  
My code:  
var CurrentUser = usersClient.Add(user);  
var CurrentUser1 = usersClient.Activate(user, true);  
where to set the password when creating a user. In my scenario, we are sending a mail to the end-user while creating the send the password.  
and where to give the option of password change after first login

Thanks in Advance

Thank you,  
T.praveen

---

<div class="post-metadata">

**Author:** ![vijet](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/vijet/32/245_2.png) [@vijet](https://devforum.okta.com/u/vijet)\
**Post date:** [August 3, 2020, 6:36pm UTC](https://devforum.okta.com/t/how-set-a-password-for-the-user-in-c-sdk/10360/2 "2020-08-03T18:36:04Z")

</div>

Hi @praveen,

To force the user to change password at the next login, you will need to to pass a query parameter `nextLogin=changePassword` to the create user call.  
I haven’t tried it out but this is the method used to create the user -

> <https://github.com/okta/okta-sdk-dotnet/blob/1849eb0d2b199d3e3fc2723bb4dc732c7b135352/src/Okta.Sdk/Generated/IUsersClient.Generated.cs#L37>

  
Notice the `Okta.Sdk.UserNextLogin nextLogin` argument to this method. You will have to set it accordingly.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [January 25, 2024, 6:16pm UTC](https://devforum.okta.com/t/how-set-a-password-for-the-user-in-c-sdk/10360/3 "2024-01-25T18:16:34Z")

</div>

Closed on January 25, 2024, 6:16pm UTC

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
