gibi özellikler tarafından nasıl listelenir? Ekran adı, Telefon ve Bölüm gibi filtreler kullanarak Active Directory'de arama yapmam gerekiyor. Görünen ad ve telefon kolay ama departmanda takılıyorum. Bu işler biraz:Active Directory'deki Kullanıcıların listesi, Bölüm
DirectoryEntry userDirectoryEntry = userPrincipal.GetUnderlyingObject() as DirectoryEntry;
if (ddlDepartment.SelectedValue != "")
userDirectoryEntry.Properties["title"].Value = ddlDepartment.SelectedValue;
Ama bu işe yaramazsa: Ben sadece böyle bir şey eklemek umuyorum
using (PrincipalContext context = new PrincipalContext(ContextType.Domain))
{
UserPrincipal userPrincipal = new UserPrincipal(context);
if (txtDisplayName.Text != "")
userPrincipal.DisplayName = "*" + txtDisplayName.Text + "*";
using (PrincipalSearcher searcher = new PrincipalSearcher(userPrincipal))
{
foreach (Principal result in searcher.FindAll())
{
DirectoryEntry directoryEntry = result.GetUnderlyingObject() as DirectoryEntry;
DataRow drName = dtProfile.NewRow();
drName["displayName"] = directoryEntry.Properties["displayName"].Value;
drName["department"] = directoryEntry.Properties["department"].Value;
dtProfile.Rows.Add(drName);
}
}
}
. Bunu nasıl yapabileceğimi bilen var mı?
Düzeltme: Ben bir aptalım, arama terimini değiştirdim ve cevabı bulundu. Ekstra alanlara katılımcılar denir. Thanks Raymund Macaalay for your blog article on extending Principals.
Benim genişletilmiş UserPrincipal:
[DirectoryObjectClass("user")]
[DirectoryRdnPrefix("CN")]
public class UserPrincipalExtended : UserPrincipal
{
public UserPrincipalExtended(PrincipalContext context) : base(context)
{
}
[DirectoryProperty("department")]
public string department
{
get
{
if (ExtensionGet("department").Length != 1)
return null;
return (string)ExtensionGet("department")[0];
}
set { this.ExtensionSet("department", value); }
}
}