I need to know how I can retrieve the ZipCode
from Active Directory. Currently, I can get the User
and Department
but I can't retrieve ZipCode
.
In the docs I can't see the ZipCode
as a property:
This is my code in C#:
using(SPSite site = new SPSite("Server"))
{
site.AllowUnsafeUpdates = true;
SPServiceContext context = SPServiceContext.GetContext(site);
UserProfileManager upm = new UserProfileManager(context);
UserProfile profile = upm.GetUserProfile(GetNodeValue("xPath"));
String department = profile[PropertyConstants.Department].Value.ToString();
String position = profile[PropertyConstants.Title].Value.ToString();
String zipCode = profile[PropertyConstants.?????].Value.ToString();
}
You need to manually map this in the User Profile Service Application first.
Properties can be added in Central Administration -> Manage Service Application - > User profile service application -> Manage User Properties -> Add User Profile Property -> Choose the Zip Code Attribute.
Now you can run another sync, each user should have this property mapped. You can then access it like you are doing but with the string name you assigned :
String zipCode = profile["SPS-ZipCode"].Value.ToString();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.