Я пытаюсь получить значение пользователя ExtensionAttribute4
.
Это мой класс расширения до UserPrincipal
:
[DirectoryRdnPrefix("CN")]
[DirectoryObjectClass("Person")]
public class UserPrincipalEx : UserPrincipal
{
// Implement the constructor using the base class constructor.
public UserPrincipalEx(PrincipalContext context) : base(context)
{ }
// Implement the constructor with initialization parameters.
public UserPrincipalEx(PrincipalContext context,
string samAccountName,
string password,
bool enabled) : base(context, samAccountName, password, enabled)
{ }
// Create the "extensionAttribute4" property.
[DirectoryProperty("extensionAttribute4")]
public string ExtensionAttribute4
{
get
{
if (ExtensionGet("extensionAttribute4").Length != 1)
return string.Empty;
return (string)ExtensionGet("extensionAttribute4")[0];
}
set { ExtensionSet("extensionAttribute4", value); }
}
public static new UserPrincipalEx FindByIdentity(PrincipalContext context, string identityValue)
{
return (UserPrincipalEx)FindByIdentityWithType(context, typeof(UserPrincipalEx), identityValue);
}
// Implement the overloaded search method FindByIdentity.
public static new UserPrincipalEx FindByIdentity(PrincipalContext context, IdentityType identityType, string identityValue)
{
return (UserPrincipalEx)FindByIdentityWithType(context, typeof(UserPrincipalEx), identityType, identityValue);
}
}
Вот как я вызываю метод:
UserPrincipalEx user = UserPrincipalEx.FindByIdentity(ctx, IdentityType.SamAccountName, "someuser");
Я вижу в отладке, что пользователь действительно является результатом Classes.UserPrincipalEx.FindByIdentity
, но extensionAttribute4
там не указан.Совсем.Другие атрибуты есть.
Я пытался сделать то же самое с менеджером, тот же результат.Ошибка:
Ссылка на объект не установлена для экземпляра объекта
Я новичок в этом, поэтому, пожалуйста, извините, если я упустил что-то очевидное.