What are the values for the 'country' field in Active Directory?

被刻印的时光 ゝ 提交于 2020-01-11 05:47:48

问题


I have a feeling Windows expects 'country' to be an integer, with 0 meaning 'US'. If that's the case, what's the mapping between integers and ISO 2-letter country codes?active


回答1:


See this link here:

ISO 3166 Country Codes

Seems to be standard ISO 3166 country codes used in several places.

Same result from this post here: Active Directory and .NET

Point 5 reads:

5. Set user's country

To set the country property for a user was one of the tasks that took me some time to figure out. After some hours of research I realized that you need to know the ISO 3166 Codes for countries and set three properties to define a user's country: c, co, and countryCode.

Best overview that includes the elusive ISO 3166 numeric codes can be found on Wikipedia - of course! (at ISO itself, you can't seem to get those lists for free - you have to pay for the privilege....)




回答2:


There's two country properties, countryCode and c, both are ISO 3166 values. The former is a number and the latter a string (ISO 3166 A2).

See ISO 3166.

Also, there's the co property which is the name of country.




回答3:


There are three different properties that must be set in Active Directory. Each is designated in the ISO 3166 standard. The ISO website has a search tool that you can use to find the official codes. Select Country codes and hit search, then click on Officially assigned... on the left.

  • c — 2 digit abbreviation (e.g. US)

    The country/region in the address of the user. The country/region is represented as a 2-character code based on ISO-3166.

  • co — Country name (e.g. United States). Microsoft got really detailed on their description for this one.

    The country/region in which the user is located.

  • countryCode — Numeric Id (e.g. 840)

    Specifies the country/region code for the user's language of choice. This value is not used by Windows 2000.

    Note: If you want to clear the country field, then you need to set this value to 0. You cannot set it to null or String.Empty. It will throw a DirectoryServicesCOMException stating "The server is unwilling to process the request" when you call CommitChanges() if you try to set it to anything other than an int.

    DirectoryEntry.Properties["countryCode"].Value = 0;
    


来源:https://stackoverflow.com/questions/4879994/what-are-the-values-for-the-country-field-in-active-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!