UserPrincipal
클래스에서 사용자의 사진을 가져올 수 없습니다. '한 단계 더 깊게'가야합니다. 예 : 밑에있는 DirectoryEntry
개체를 얻은 다음 어떤 AD 속성이 사진을 유지하고 있는지 파악합니다.
using (var ctx = new PrincipalContext(ContextType.Domain,
_webApiServiceConfiguration.Domain,
_webApiServiceConfiguration.DomainAccessUserName,
_webApiServiceConfiguration.DomainAccessPassword))
{
UserPrincipal userAd = UserPrincipal.FindByIdentity(ctx,user.USERID);
// if not null, get the underlying DirectoryEntry
if (userAd != null)
{
DirectoryEntry de = userAd.GetUnderlyingObject() as DirectoryEntry;
// if de is not null
if (de != null)
{
// get the property in question - possibly the "photo" property
if(de.Properties["photo"] != null)
{
// unlike a database column, an AD property can contain *multiple* values....
}
}
}
는 또한 : 그 "바이너리"속성은 종종 너무 좋아 재산에서 사진에 대한 정확한 바이너리 바이트를 찾아 낼 것으로 예상하지 않는다 AD로 인코딩됩니다 - 일부 변환하거나 뭔가를해야 할 수도 있습니다 ... ...
"사진을 Active Directory에서 가져 오는 중"또는 뭔가를 검색하고 싶을 수 있습니다. 정확하게 수행하는 방법에 대한 많은 게시물이 있습니다. 예 : this question & answer은 코드를 보여줍니다. DirectoryEntry
개체에도 jpegPhoto
및 thumbnailPhoto
속성이있는 것 같습니다. (어느 것이 실제로 광고에 채워지는지 확인해야합니다.)