我对 LDAP 特别陌生,想知道是否有一种方法可以知道在特定域的事件目录中填充了哪些信息。
例如,我正在尝试使用以下方式获取组织员工的形象
var bytes = directoryEntry.Properties["thumbnailPhoto"].Value;
但这会返回 null。现在我想知道图像是否存在,也许我没有正确获取图像或者没有图像?
最佳答案
这样试试
var data = user.Properties["thumbnailPhoto"].Value as byte[];
if (data != null)
using (var s = new MemoryStream(data))
return Bitmap.FromStream(s);
else
foreach (PropertyValueCollection p in user.Properties)
Trace.WriteLine(p.PropertyName);
仔细检查该属性,它可能是 jpegPhoto
byte[] data = user.Properties["jpegPhoto"].Value as byte[];
来源:
关于c# - 从 Active Directory c# 检索图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50287037/