Как добавить атрибут Manager в Active Directory с помощью PrincipLOCNEXT с использованием ASP.NETC#

Место общения программистов C#
Ответить
Anonymous
 Как добавить атрибут Manager в Active Directory с помощью PrincipLOCNEXT с использованием ASP.NET

Сообщение Anonymous »

Я создаю пользователя по

Код: Выделить всё

PrincipalContext
в Active Directory. Я хочу добавить несколько дополнительных атрибутов, таких как местоположение, инициалы, сотрудники и менеджер. Но я не могу присвоить значение атрибуту менеджера.

Код: Выделить всё

 PrincipalContext ouContext = new PrincipalContext(ContextType.Domain, AD.ServerDomain, container, AD.LDAPUser, AD.LDAPPasswoprd);
UserPrincipalEx user = new UserPrincipalEx(ouContext);
user.GivenName = txtGivenName.Text;
user.Surname = txtSurName.Text;
user.DisplayName = Convert.ToString(txtDisplayName.Text);
user.Manager = txtSupervisor.Text; // What should I assign in this field
user.SetPassword("welcome1*");
user.Enabled = true;
user.ExpirePasswordNow();
user.Save();    // Here I am getting the error
< /code>
My Extension Class: < /p>
[DirectoryObjectClass("user")]
[DirectoryRdnPrefix("CN")]

public class UserPrincipalEx : UserPrincipal
{
public UserPrincipalEx(PrincipalContext context) : base(context) { }
public UserPrincipalEx(PrincipalContext context, string samAccountName, string password, bool enabled) : base(context, samAccountName, password, enabled) { }

public static new UserPrincipalEx FindByIdentity(PrincipalContext context,
string identityValue)
{
return (UserPrincipalEx)FindByIdentityWithType(context,
typeof(UserPrincipalEx),
identityValue);
}
public static new UserPrincipalEx FindByIdentity(PrincipalContext context,
IdentityType identityType,
string identityValue)
{
return (UserPrincipalEx)FindByIdentityWithType(context,
typeof(UserPrincipalEx),
identityType,
identityValue);
}
[DirectoryProperty("distinguishedName")]
public string DistinguishedName
{
get
{
if (ExtensionGet("distinguishedName").Length != 1)
return null;
return (string)ExtensionGet("distinguishedName")[0];
}
set
{
ExtensionSet("distinguishedName", value);
}
}

[DirectoryProperty("manager")]
public string Manager
{
get
{
if (ExtensionGet("manager").Length != 1)
return null;
return (string)ExtensionGet("manager")[0];
}
set
{
ExtensionSet("manager", value);
}
}
Пожалуйста, помогите мне решить эту проблему и как назначить значения в поле менеджера?


Подробнее здесь: https://stackoverflow.com/questions/241 ... sing-asp-n
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»