如何更改用户在Active Directory登录名 [英] How to change login name of user in Active Directory
问题描述
我想在用户从Active Directory我的.NET应用程序登录改变。
I want to change in my .NET application login of user from Active Directory.
我改变了它以这种方式现在:
I'm changing it in this way now:
DirectoryEntry userToUpdate = updatedUser.GetDirectoryEntry();
userToUpdate.Properties["sAMAccountName"].Value = user.NewLogin;
userToUpdate.CommitChanges();
但是,如我所料不工作。当我检查ADActive Directory用户和计算机项为这个用户,然后在选项卡账户我看到:
- 用户登录名属性没有更新
- 用户登录名(pre-Windows 2000)的属性被正确地将更新。
But it doesn't work as I expect. When I'm checking in AD "Active Directory Users and Computers" entry for this user then on tab "account" I see that:
- "User logon name" property isn't updated
- "User logon name (pre-Windows 2000)" property is correcly updated.
如何更新从C#code正确的登录名的广告?我应该在的DirectoryEntry设置什么属性,或者有其他方法来更改登录名。
How to update correctly login name in AD from C# code? What property should I set in DirectoryEntry, or there is another method to change login name.
推荐答案
有两个登录名在AD:
sAMAccountName = User logon name, (pre-windows 2000)
Format/Usage: domain\user.name (note, your code will only populate user.name)
userPrincipalName = User logon name
Format/Usage: user.name@domain.local
您需要同时更新。
这篇关于如何更改用户在Active Directory登录名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!