• Products
    • View all products
    • Free trials
  • Solutions
    • All Solutions
    • All Integrations
  • Resources
    • All Resources
    • Learning Hub
  • Trials
  • Support
    • Support Home
    • By Product
      • All Products
      • Active Roles
      • Authentication Services
      • Cloud Access Manager
      • Defender
      • Identity Manager
      • Password Manager
      • Safeguard
      • Starling Identity Analytics & Risk Intelligence
      • Starling Two-Factor Authentication
      • TPAM Appliance
    • Contact Support
      • Overview
      • Customer Service
      • Licensing Assistance
      • Renewal Assistance
      • Technical Support
    • Download Software
    • Knowledge Base
    • My Account
      • My Products
      • My Service Requests
      • My Licenses
      • My Groups
      • My Profile
    • Policies & Procedures
    • Professional Services
    • Technical Documentation
    • One Identity University
    • User Forums
    • Video Tutorials
  • Partners
    • Overview
    • Partner Circle Log In
    • Become a Partner
    • Find a Partner
    • Partner Community
  • Communities
    • Home
    • Blogs
      • Blogs A to Z
      • One Identity Community
      • AD Account Lifecycle Management
      • Cloud
      • Identity Governance & Administration
      • Privileged Access Management
      • syslog-ng Community
    • Forums
      • All Product Forums
      • Active Roles
      • Identity Manager
      • Password Manager
      • Safeguard
      • Unix Access Management
    • Social Networks
      • Facebook
      • LinkedIn
      • Twitter
      • YouTube
One Identity Community
One Identity Community
  • Site
  • User
  • Site
  • Search
  • User
Active Roles Community
Active Roles Community
Wiki Set correct country code for user
  • Forum
  • Ideas
  • Wiki
  • More
  • Cancel
  • New
  • -Active Roles Script Center
    • +Active Roles Script Policy Best Practices
    • Active Roles SDK
    • +C#
    • +JavaScript
    • +PowerShell
    • -VBScript
      • VBScript Library source code
      • -VBScript samples
        • A Managed Unit with users which have not logged on for last 90 days
        • Adjust the case of usernames to title case (first letter of each part of the name)
        • Advanced group creation/provision
        • Advanced shared folder creation
        • Bulk policy incompliance fixing
        • Check unique value of an attribute
        • +Computer management
        • +Exchange management
        • Function that converts regular date into integer8 format
        • Get effective policy info list
        • +Group management
        • How to find a request source in script policy
        • How to send emails based on scripts policy parameters and Virtual Attribute values
        • +Permissions Management
        • Policy incompliance reporting & fixing for specified policy
        • Populate values from a SQL database to an AD Attribute
        • Prevent copying an attribute on user copy
        • Prohibite a permission propagation to AD
        • Prohibite an AD native security editing
        • Read large integer date attributes and display them in date and time readable format
        • Read XML Node text or attribute value
        • Read XML Node with Children into DictionaryObject
        • Standalone script that requests built-in password generation policy
        • -User management
          • Copy additional attributes on user copy
          • Create/Delete local user accounts, basing upon creation/deletion of user accounts in Active Directory
          • Custom script-based PVG-policy with generation rule
          • Custom script-based PVG-policy with possible values list
          • Custom script-based User Logon Name Generation policy
          • Delete Expired Users and Home Directory
          • Detailed debug information on the script policy request object
          • Function to get a DN of a user object using samAccountName
          • Get user account properties after it had been deleted
          • How to enable cross-domain moving of user accounts
          • How to enforce the use of the "Generate Password" function
          • How to prevent Active Roles interaction with file servers on User Home Folder Provision
          • How to prohibit specifying a user password that never expires
          • Last Bad Password Time
          • Manage country codes, names and abbreviations
          • Move a user to some OU upon creation
          • Notify manager when user object is deprovisioned
          • Populate a PVG policy with a possible values list from external source
          • Populate user attributes based on another attribute - e.g. 'Company'
          • Programmatically deprovision a user
          • Re-locates users according to a value set in a virtual attribute
          • Remove characters with an umlaute (öäü) and replace with corresponding characters
          • Restrict who can Disable users while allowing Enable
          • Review for user personal data
          • Script Policy to set account expiration for every created user account
          • Script-based "Last N characters of X attribute"-rule as part of User Logon Name Generation policy rules
          • Set correct country code for user
          • Simplified version of the script-based PVG-policy with a possible values list
          • Stamping manager DN by given manager Id
          • Standalone script to set logon hours of a user account
          • Tree of trust - allow objects to be managed only by their direct or indirect managers
          • User logon name generation without national characters
          • User Provisioning - Home Drive Location and Profile based on UserID
        • Validate moving operations
        • +VBScript: Approval

You are currently reviewing an older revision of this page.

  • History View current version

Set correct country code for user

Back to User management: Other

DESCRIPTION

When using Quick Connect to sync from your HR environment with your AD environment, it does not properly set the country code. It sets the country name, but not the "code". To have a fully functioning environment, you need both. This script sets the second one when the first one is changed. You must call it as part of a policy script.


Note This code may use functions from the ARS Script Policy Best Practices. Please, follow the link to obtain instructions and code for those functions.


SCRIPT

 

'*********************************************************************************

' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,

' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED

' WARRANTIES OF MERCHANTBILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

'

' IF YOU WANT THIS FUNCTIONALITY TO BE CONDITIONALLY SUPPORTED,

' PLEASE CONTACT QUEST PROFESSIONAL SERVICES.

'*********************************************************************************

'

' This code is published on the ActiveRoles Script Center:

' http://communities.quest.com/docs/DOC-9991

'

' This code may use functions from the ARS Script Policy Best Practices:

' http://communities.quest.com/docs/DOC-10016

'

' Please, follow the link to obtain instructions and code for those functions.

'*********************************************************************************

'Function to set correct country code

Function setcountry(country,objUser)

Select Case country

Case "Afghanistan" objUser.put "c" , "AF"

Case "Åland Islands" objUser.put "c" , "AX"

Case "Albania" objUser.put "c" , "AL"

Case "Algeria" objUser.put "c" , "DZ"

Case "American Samoa" objUser.put "c" , "AS"

Case "Andorra" objUser.put "c" , "AD"

Case "Angola" objUser.put "c" , "AO"

Case "Anguilla" objUser.put "c" , "AI"

Case "Antarctica" objUser.put "c" , "AQ"

Case "Antigua and Barbuda" objUser.put "c" , "AG"

Case "Argentina" objUser.put "c" , "AR"

Case "Armenia" objUser.put "c" , "AM"

Case "Aruba" objUser.put "c" , "AW"

Case "Australia" objUser.put "c" , "AU"

Case "Austria" objUser.put "c" , "AT"

Case "Azerbaijan" objUser.put "c" , "AZ"

Case "Bahamas" objUser.put "c" , "BS"

Case "Bahrain" objUser.put "c" , "BH"

Case "Bangladesh" objUser.put "c" , "BD"

Case "Barbados" objUser.put "c" , "BB"

Case "Belarus" objUser.put "c" , "BY"

Case "Belgium" objUser.put "c" , "BE"

Case "Belize" objUser.put "c" , "BZ"

Case "Benin" objUser.put "c" , "BJ"

Case "Bermuda" objUser.put "c" , "BM"

Case "Bhutan" objUser.put "c" , "BT"

Case "Bolivia" objUser.put "c" , "BO"

Case "Bosnia and Herzegovina" objUser.put "c" , "BA"

Case "Botswana" objUser.put "c" , "BW"

Case "Bouvet Island" objUser.put "c" , "BV"

Case "Brazil" objUser.put "c" , "BR"

Case "British Indian Ocean Territory" objUser.put "c" , "IO"

Case "Brunei Darussalam" objUser.put "c" , "BN"

Case "Bulgaria" objUser.put "c" , "BG"

Case "Burkina Faso" objUser.put "c" , "BF"

Case "Burundi" objUser.put "c" , "BI"

Case "Cambodia" objUser.put "c" , "KH"

Case "Cameroon" objUser.put "c" , "CM"

Case "Canada" objUser.put "c" , "CA"

Case "Cape Verde" objUser.put "c" , "CV"

Case "Cayman Islands" objUser.put "c" , "KY"

Case "Central African Republic" objUser.put "c" , "CF"

Case "Chad" objUser.put "c" , "TD"

Case "Chile" objUser.put "c" , "CL"

Case "China, People's Republic of" objUser.put "c" , "CN"

Case "China" objUser.put "c" , "CN"

Case "Christmas Island" objUser.put "c" , "CX"

Case "Cocos (Keeling) Islands" objUser.put "c" , "CC"

Case "Colombia" objUser.put "c" , "CO"

Case "Comoros" objUser.put "c" , "KM"

Case "Congo, Republic of the" objUser.put "c" , "CG"

Case "Congo, The Democratic Republic Of The" objUser.put "c" , "CD"

Case "Cook Islands" objUser.put "c" , "CK"

Case "Costa Rica" objUser.put "c" , "CR"

Case "Côte d'Ivoire" objUser.put "c" , "CI"

Case "Croatia" objUser.put "c" , "HR"

Case "Cuba" objUser.put "c" , "CU"

Case "Cyprus" objUser.put "c" , "CY"

Case "Czech Republic" objUser.put "c" , "CZ"

Case "Denmark" objUser.put "c" , "DK"

Case "Djibouti" objUser.put "c" , "DJ"

Case "Dominica" objUser.put "c" , "DM"

Case "Dominican Republic" objUser.put "c" , "DO"

Case "Ecuador" objUser.put "c" , "EC"

Case "Egypt" objUser.put "c" , "EG"

Case "El Salvador" objUser.put "c" , "SV"

Case "Equatorial Guinea" objUser.put "c" , "GQ"

Case "Eritrea" objUser.put "c" , "ER"

Case "Estonia" objUser.put "c" , "EE"

Case "Ethiopia" objUser.put "c" , "ET"

Case "European Union" objUser.put "c" , "EU"

Case "Falkland Islands" objUser.put "c" , "FK"

Case "Faroe Islands" objUser.put "c" , "FO"

Case "Fiji" objUser.put "c" , "FJ"

Case "Finland" objUser.put "c" , "FI"

Case "France" objUser.put "c" , "FR"

Case "French Guiana" objUser.put "c" , "GF"

Case "French Polynesia" objUser.put "c" , "PF"

Case "French Southern Territories" objUser.put "c" , "TF"

Case "Gabon" objUser.put "c" , "GA"

Case "Gambia" objUser.put "c" , "GM"

Case "Georgia" objUser.put "c" , "GE"

Case "Germany" objUser.put "c" , "DE"

Case "Ghana" objUser.put "c" , "GH"

Case "Gibraltar" objUser.put "c" , "GI"

Case "Greece" objUser.put "c" , "GR"

Case "Greenland" objUser.put "c" , "GL"

Case "Grenada" objUser.put "c" , "GD"

Case "Guadeloupe" objUser.put "c" , "GP"

Case "Guam" objUser.put "c" , "GU"

Case "Guatemala" objUser.put "c" , "GT"

Case "Guinea" objUser.put "c" , "GN"

Case "Guinea-Bissau" objUser.put "c" , "GW"

Case "Guyana" objUser.put "c" , "GY"

Case "Haiti" objUser.put "c" , "HT"

Case "Heard Island and McDonald Islands" objUser.put "c" , "HM"

Case "Honduras" objUser.put "c" , "HN"

Case "Hong Kong" objUser.put "c" , "HK"

Case "Hungary" objUser.put "c" , "HU"

Case "Iceland" objUser.put "c" , "IS"

Case "India" objUser.put "c" , "IN"

Case "Indonesia" objUser.put "c" , "ID"

Case "Iran, Islamic Republic of" objUser.put "c" , "IR"

Case "Iraq" objUser.put "c" , "IQ"

Case "Ireland" objUser.put "c" , "IE"

Case "Israel" objUser.put "c" , "IL"

Case "Italy" objUser.put "c" , "IT"

Case "Jamaica" objUser.put "c" , "JM"

Case "Japan" objUser.put "c" , "JP"

Case "Jordan" objUser.put "c" , "JO"

Case "Kazakhstan" objUser.put "c" , "KZ"

Case "Kenya" objUser.put "c" , "KE"

Case "Kiribati" objUser.put "c" , "KI"

Case "Korea, Democratic People's Republic of" objUser.put "c" , "KP"

Case "Korea, Republic of" objUser.put "c" , "KR"

Case "Korea" objUser.put "c" , "KR"

Case "Kuwait" objUser.put "c" , "KW"

Case "Kyrgyzstan" objUser.put "c" , "KG"

Case "Lao People's Democratic Republic" objUser.put "c" , "LA"

Case "Latvia" objUser.put "c" , "LV"

Case "Lebanon" objUser.put "c" , "LB"

Case "Lesotho" objUser.put "c" , "LS"

Case "Liberia" objUser.put "c" , "LR"

Case "Libyan Arab Jamahiriya" objUser.put "c" , "LY"

Case "Liechtenstein" objUser.put "c" , "LI"

Case "Lithuania" objUser.put "c" , "LT"

Case "Luxembourg" objUser.put "c" , "LU"

Case "Macao" objUser.put "c" , "MO"

Case "Macedonia, The Former Yugoslav Republic of" objUser.put "c" , "MK"

Case "Madagascar" objUser.put "c" , "MG"

Case "Malawi" objUser.put "c" , "MW"

Case "Malaysia" objUser.put "c" , "MY"

Case "Maldives" objUser.put "c" , "MV"

Case "Mali" objUser.put "c" , "ML"

Case "Malta" objUser.put "c" , "MT"

Case "Marshall Islands" objUser.put "c" , "MH"

Case "Martinique" objUser.put "c" , "MQ"

Case "Mauritania" objUser.put "c" , "MR"

Case "Mauritius" objUser.put "c" , "MU"

Case "Mayotte" objUser.put "c" , "YT"

Case "Mexico" objUser.put "c" , "MX"

Case "Micronesia, Federated States of" objUser.put "c" , "FM"

Case "Moldova, Republic of" objUser.put "c" , "MD"

Case "Monaco" objUser.put "c" , "MC"

Case "Mongolia" objUser.put "c" , "MN"

Case "Montserrat" objUser.put "c" , "MS"

Case "Morocco" objUser.put "c" , "MA"

Case "Mozambique" objUser.put "c" , "MZ"

Case "Myanmar" objUser.put "c" , "MM"

Case "Namibia" objUser.put "c" , "NA"

Case "Nauru" objUser.put "c" , "NR"

Case "Nepal" objUser.put "c" , "NP"

Case "Netherlands" objUser.put "c" , "NL"

Case "Netherlands Antilles" objUser.put "c" , "AN"

Case "New Caledonia" objUser.put "c" , "NC"

Case "New Zealand" objUser.put "c" , "NZ"

Case "Nicaragua" objUser.put "c" , "NI"

Case "Niger" objUser.put "c" , "NE"

Case "Nigeria" objUser.put "c" , "NG"

Case "Niue" objUser.put "c" , "NU"

Case "Norfolk Island" objUser.put "c" , "NF"

Case "Northern Mariana Islands" objUser.put "c" , "MP"

Case "Norway" objUser.put "c" , "NO"

Case "Oman" objUser.put "c" , "OM"

Case "Pakistan" objUser.put "c" , "PK"

Case "Palau" objUser.put "c" , "PW"

Case "Palestinian Territory, Occupied" objUser.put "c" , "PS"

Case "Panama" objUser.put "c" , "PA"

Case "Papua New Guinea" objUser.put "c" , "PG"

Case "Paraguay" objUser.put "c" , "PY"

Case "Peru" objUser.put "c" , "PE"

Case "Philippines" objUser.put "c" , "PH"

Case "Pitcairn" objUser.put "c" , "PN"

Case "Poland" objUser.put "c" , "PL"

Case "Portugal" objUser.put "c" , "PT"

Case "Puerto Rico" objUser.put "c" , "PR"

Case "Qatar" objUser.put "c" , "QA"

Case "Réunion" objUser.put "c" , "RE"

Case "Romania" objUser.put "c" , "RO"

Case "Russian Federation" objUser.put "c" , "RU"

Case "Russia" objUser.put "c" , "RU"

Case "Rwanda" objUser.put "c" , "RW"

Case "Saint Helena" objUser.put "c" , "SH"

Case "Saint Kitts and Nevis" objUser.put "c" , "KN"

Case "Saint Lucia" objUser.put "c" , "LC"

Case "Saint-Pierre and Miquelon" objUser.put "c" , "PM"

Case "Saint Vincent and the Grenadines" objUser.put "c" , "VC"

Case "Samoa" objUser.put "c" , "WS"

Case "San Marino" objUser.put "c" , "SM"

Case "São Tomé and Príncipe" objUser.put "c" , "ST"

Case "Saudi Arabia" objUser.put "c" , "SA"

Case "Senegal" objUser.put "c" , "SN"

Case "Serbia and Montenegro" objUser.put "c" , "CS"

Case "Seychelles" objUser.put "c" , "SC"

Case "Sierra Leone" objUser.put "c" , "SL"

Case "Singapore" objUser.put "c" , "SG"

Case "Slovakia" objUser.put "c" , "SK"

Case "Slovenia" objUser.put "c" , "SI"

Case "Solomon Islands" objUser.put "c" , "SB"

Case "Somalia" objUser.put "c" , "SO"

Case "South Africa" objUser.put "c" , "ZA"

Case "South Georgia and the South Sandwich Islands" objUser.put "c" , "GS"

Case "Spain" objUser.put "c" , "ES"

Case "Sri Lanka" objUser.put "c" , "LK"

Case "Sudan" objUser.put "c" , "SD"

Case "Suriname" objUser.put "c" , "SR"

Case "Svalbard and Jan Mayen" objUser.put "c" , "SJ"

Case "Swaziland" objUser.put "c" , "SZ"

Case "Sweden" objUser.put "c" , "SE"

Case "Switzerland" objUser.put "c" , "CH"

Case "Syrian Arab Republic" objUser.put "c" , "SY"

Case "Taiwan (Republic of China)" objUser.put "c" , "TW"

Case "Tajikistan" objUser.put "c" , "TJ"

Case "Tanzania, United Republic Of" objUser.put "c" , "TZ"

Case "Thailand" objUser.put "c" , "TH"

Case "Timor-Leste" objUser.put "c" , "TL"

Case "Togo" objUser.put "c" , "TG"

Case "Tokelau" objUser.put "c" , "TK"

Case "Tonga" objUser.put "c" , "TO"

Case "Trinidad and Tobago" objUser.put "c" , "TT"

Case "Tunisia" objUser.put "c" , "TN"

Case "Turkey" objUser.put "c" , "TR"

Case "Turkmenistan" objUser.put "c" , "TM"

Case "Turks and Caicos Islands" objUser.put "c" , "TC"

Case "Tuvalu" objUser.put "c" , "TV"

Case "Uganda" objUser.put "c" , "UG"

Case "Ukraine" objUser.put "c" , "UA"

Case "United Arab Emirates" objUser.put "c" , "AE"

Case "United Kingdom" objUser.put "c" , "GB"

Case "United States" objUser.put "c" , "US"

Case "United States Minor Outlying Islands" objUser.put "c" , "UM"

Case "Uruguay" objUser.put "c" , "UY"

Case "Uzbekistan" objUser.put "c" , "UZ"

Case "Vanuatu" objUser.put "c" , "VU"

Case "Vatican City State" objUser.put "c" , "VA"

Case "Venezuela" objUser.put "c" , "VE"

Case "Viet Nam" objUser.put "c" , "VN"

Case "Virgin Islands, British" objUser.put "c" , "VG"

Case "Virgin Islands, U.S." objUser.put "c" , "VI"

Case "Wallis and Futuna" objUser.put "c" , "WF"

Case "Western Sahara" objUser.put "c" , "EH"

Case "Yemen" objUser.put "c" , "YE"

Case "Zambia" objUser.put "c" , "ZM"

Case "Zimbabwe" objUser.put "c" , "ZW"

End Select

objUser.setinfo

'***** END OF CODE ***************************************************************

COMPATIBILITY

Script compatible with the following version(s): <Not specified>

Back to User management: Other

  • Company
    • About Us
    • Buy
    • Careers
    • Contact Us
    • News
  • Resources
    • Blogs
    • Customer Stories
    • Documents
    • Events
    • Videos
  • Support
    • Professional Services
    • Renew Support
    • Technical Support
    • One Identity University
    • Support Service
  • Social Networks
    • Facebook
    • Instagram
    • LinkedIn
    • Twitter
    • YouTube
  • © 2025 One Identity LLC. ALL RIGHTS RESERVED.
  • Legal
  • Terms of Use
  • Privacy
  • Community Feedback & Support
  • Cookie Preference Center