# OKTA SDK DotNet: How do I force a user to change password

**URL:** <https://devforum.okta.com/t/okta-sdk-dotnet-how-do-i-force-a-user-to-change-password/12618>\
**Category:** Questions\
**Created:** [January 25, 2021, 8:38pm UTC](https://devforum.okta.com/t/okta-sdk-dotnet-how-do-i-force-a-user-to-change-password/12618 "2021-01-25T20:38:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rcorkery](https://avatars.discourse-cdn.com/v4/letter/r/a4c791/32.png) [@rcorkery](https://devforum.okta.com/u/rcorkery)\
**Post date:** [January 25, 2021, 8:38pm UTC](https://devforum.okta.com/t/okta-sdk-dotnet-how-do-i-force-a-user-to-change-password/12618/1 "2021-01-25T20:38:42Z")

</div>

When a user signs on for the first time, I want to force the user to change the password they are given.

I am able to create the user with a password.

And then activate the user, with an email (which is what I want). (See below)

But, I can not figure out a way, using the OKTA SDK for dotNote, to then expire the password to force the user to change it.

I did find information related to nextLogin = changePassword. But, I can’t seem to figure out how to use it with the SDK. (See below.)

Within the SDK there is a UserNextLogin class but I don’t know if that as anything to do with it.

Any help would be appreciated.

```
        var oktaUser = await client.Users.CreateUserAsync(new CreateUserWithPasswordOptions
        {
            // User profile object
            Profile = new UserProfile
            {
                FirstName = "Anakin8",
                LastName = "Skywalker8",
                Email = "test@gmail.com",
                Login = "darth.vader12345678",
                
            },
            Password = "D1sturB1ng!",
            Activate = false,
        });

        await oktaUser.ActivateAsync(sendEmail: false);

        var userNestNextLogin = UserNextLogin.ChangePassword;
```

---

<div class="post-metadata">

**Author:** ![erin.p](https://avatars.discourse-cdn.com/v4/letter/e/e480ec/32.png) [@erin.p](https://devforum.okta.com/u/erin.p)\
**Post date:** [January 25, 2021, 11:47pm UTC](https://devforum.okta.com/t/okta-sdk-dotnet-how-do-i-force-a-user-to-change-password/12618/2 "2021-01-25T23:47:33Z")

</div>

Hi @rcorkery

If you take a look at the [SDK source code](https://github.com/okta/okta-sdk-dotnet/blob/1849eb0d2b199d3e3fc2723bb4dc732c7b135352/src/Okta.Sdk/Generated/IUsersClient.Generated.cs#L37), you’ll see that you actually need to pass `nextLogin=changePassword` in as a query parameter to `CreateUserAsync` in order to prompt the user to change their password the next time they log in.

---

<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 26, 2024, 6:15pm UTC](https://devforum.okta.com/t/okta-sdk-dotnet-how-do-i-force-a-user-to-change-password/12618/3 "2024-01-26T18:15:20Z")

</div>

Closed on January 26, 2024, 6:15pm UTC

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