Is there a way to set a new user's domain suffix through the UserPrincipal class?

谁都会走 提交于 2019-12-24 13:42:47

问题


through the UserPrincipal Class I can set the UserPrincipalName and thus when my user is created the first part of the User logon name is populated:

up.UserPrincipalName = "ryan.anthony3"; produces the following result:

however that drop down is empty unless I choose one of the options through the interface

I'd like to set one of the available options programmatically using this UserPrincipal class if possible... is that possible?

I am not seeing a setter for it here: http://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.userprincipal%28v=vs.110%29.aspx


回答1:


UserPrincipalName is what you're looking for.

Use up.UserPrincipalName = "ryan.anthony3@yourDomain.Com";




回答2:


User Principal Name in Active Directory, looks in the GUI tools, like it has two components, the parts on either side of the @ sign.

But in reality the database stores it as a single string.

The splitting of the two components is just meant as a convenience for administrators only.

When you set the value, you must set the complete value. AD does NOT validate the string you enter, you can in fact enter complete nonsense and it will accept it. (It won't 'work' for useful things, but it will accept it).



来源:https://stackoverflow.com/questions/20710535/is-there-a-way-to-set-a-new-users-domain-suffix-through-the-userprincipal-class

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