2

通过 UserPrincipal 类我可以设置 UserPrincipalName ,因此当我的用户被创建时,用户登录名的第一部分被填充:

up.UserPrincipalName = "ryan.anthony3";产生以下结果:

在此处输入图像描述

但是,除非我通过界面选择其中一个选项,否则该下拉菜单为空

如果可能,我想使用此 UserPrincipal 类以编程方式设置可用选项之一……这可能吗?

我在这里没有看到它的设置器:http: //msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.userprincipal%28v=vs.110%29.aspx

4

2 回答 2

4

UserPrincipalName is what you're looking for.

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

于 2013-12-21T19:27:58.517 回答
3

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).

于 2014-02-10T01:06:45.720 回答