简体   繁体   English

如何通过c#更新AD用户的全名(非显示名)

[英]How to update AD User's Full name (Not Display Name) via c#

Existing answers confuse "Full name" with Display name. 现有答案将“全名”与显示名混淆。 I can update AD user properties via c# (eg I can update First name, Last name, Display name) but not "Full name" 我可以通过c#更新AD用户属性(例如,我可以更新名字,姓氏,显示名称),但不能更新“全名”

To see Full name search for a user in AD and in results right click on name and select Rename and "Full name" field is displayed along with name surname and display name 要查看在AD中搜索用户的全名并在结果中右键单击名称,然后选择“重命名”,将显示“全名”字段以及姓名和显示名称

"Full name" is different from Display name (or name/surname or combinations) and can have different value. “全名”与显示名称(或名称/姓氏或组合)不同,并且可以具有不同的值。 By default Full name is set to username and I need to change it to be same as display name. 默认情况下,全名设置为用户名,我需要将其更改为与显示名相同。

Does anyone know how to update 'Full name' value using c#? 有谁知道如何使用C#更新“全名”值? Thanks 谢谢

It is actually rename method that changes the full name, (or the name shown in results when queried via manual AD search. 实际上是重命名方法,它会更改全名(或通过手动AD搜索查询时结果中显示的名称)。

string myNewValue = "mySurname, myFirstName".Replace(",", "\\,"); //escape comma
userDirectoryEntry.Rename("CN=" + myNewValue);
userDirectoryEntry.CommitChanges();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM