<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
System Status
Announcements
Announcements
Search
Search
Select Language
0D54z000075XpGMCA0Okta Classic EngineAPI Access ManagementAnswered2023-08-07T21:02:45.000Z2021-08-06T07:08:54.000Z2021-08-10T14:57:21.000Z

VinodhM.45873 (Customer) asked a question.

How to get the custom user profile attributes using Okta's .Net API?

Hello

We have 100's of thousands of user in Okta. We have a custom user profile attribute configured in Okta called "digital_home_user_id". This maps to a user id from an internal applications. This value is not set properly for 30% of the user in our Okta. And this has become a mandatory attribute recently. So, here is what we want to do.

 

1) Use the .Net (C*) Okta API to get the user list. Either using GetUserAsync or ListUsers.

2) Check the Custom attribute called "digital_home_user_id" to see if it has a value.

3) If it is null or empty (for a user), then get the corresponding value from the internal system and update Okta.

 

However, the problem is, the user profile doesn't include the custom attributes. So, "digital_home_user_id" does not exist in the response.

 

Question:

How to get the custom attribute and update the value using Okta's .Net API?

 

I browsed through a lot of similar questions, but none has any helpful answers. Appreciate any help you could provide.

 

Thanks,

Vinodh


  • User16031265193733863689 (Developer Support)

    Hello Vinodh,

    When you state,

    the user profile doesn't include the custom attributes. So, "digital_home_user_id" does not exist in the response

     

    I assume the Okta user type has a custom attribute "digital_home_user_id" setup, but from within the .NET Management SDK there is not Get/Set field for the custom attribute?

     

    Assuming the above it true, if you want to set a custom attribute from the .NET SDK you could do something like,

     

          var foundUsers = await client.Users

                .ListUsers(search: $"profile.login eq \"igor.dean3@mail.com\"")

                .ToArrayAsync();

          var digital_home_user_id = foundUsers.First().Profile.GetProperty<String>("digital_home_user_id");

          Console.WriteLine("digital_home_user_id=" + digital_home_user_id);

          if (digital_home_user_id == null || digital_home_user_id.Equals("")) {

            foundUsers.First().Profile.SetProperty("digital_home_user_id", "My Digital Id");

            await foundUsers.First().UpdateAsync();

          }

     

     

    Expand Post
    Selected as Best
  • User16031265193733863689 (Developer Support)

    Hello Vinodh,

    When you state,

    the user profile doesn't include the custom attributes. So, "digital_home_user_id" does not exist in the response

     

    I assume the Okta user type has a custom attribute "digital_home_user_id" setup, but from within the .NET Management SDK there is not Get/Set field for the custom attribute?

     

    Assuming the above it true, if you want to set a custom attribute from the .NET SDK you could do something like,

     

          var foundUsers = await client.Users

                .ListUsers(search: $"profile.login eq \"igor.dean3@mail.com\"")

                .ToArrayAsync();

          var digital_home_user_id = foundUsers.First().Profile.GetProperty<String>("digital_home_user_id");

          Console.WriteLine("digital_home_user_id=" + digital_home_user_id);

          if (digital_home_user_id == null || digital_home_user_id.Equals("")) {

            foundUsers.First().Profile.SetProperty("digital_home_user_id", "My Digital Id");

            await foundUsers.First().UpdateAsync();

          }

     

     

    Expand Post
    Selected as Best
    • VinodhM.45873 (Customer)

      Hello Erik,

      Perfect! This is exactly what I was looking for. Appreciate your prompt response. Thank you.

       

      Thanks,

      Vinodh

This question is closed.
Loading
How to get the custom user profile attributes using Okta's .Net API?
Okta Support Agent (Beta)

Terms of Service

Hello! I'm the Okta Support Agent (Beta), your go-to resource for questions about Okta products. Please remember for your security and privacy, do not share any Personally Identifiable Information (PII) such as passwords, IP addresses, or other details with me.

Okta Privacy Policy and Terms of Service apply