更新已使用自定义属性扩展的AD UserPrincipal

时间:2011-05-23 12:02:45

标签: c# active-directory

我再次陷入AD。任何人都可以指出我如何更新已使用[DirectoryProperty(“Title”)]样式属性扩展的UserPrincipal(C#)的示例方向?

我可以创建用户,但是当我找回他时,他又是一个UserPrincipal,而不是我的扩展类。我试过像这样构建我的扩展类

ADUserClassExtensions userExt = new ADUserClassExtensions(ctx, userOfInterest.SamAccountName, "******", true);

希望它能让我设置属性然后保存它。但它(正确地)抱怨用户已经存在,因为我正在做一个Save(),我在那里看不到Update()方法。

建议的方法是什么?谷歌搜索了一下,找不到任何东西。

非常感谢

2 个答案:

答案 0 :(得分:0)

以下是使用扩展性调用执行此操作的示例,因为它是shown in this other article

答案 1 :(得分:0)

在扩展课程中:

public static new ADUserClassExtensions GetPrincipalByIdentity(PrincipalContext ctx, string identityValue) 
{
    return (ADUserClassExtensions) Principal.FindByIdentityWithType(ctx, typeof(ADUserClassExtensions), identityValue);  
} 
相关问题