c# - 从 Active Directory c# 检索图片

标签 c# authentication active-directory ldap

enter image description here

我对 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[];

来源:

https://social.msdn.microsoft.com/Forums/vstudio/en-US/02690cfa-c2c1-43d7-9f82-7d210cb86267/c-code-to-add-and-retrieve-user-photos-from-active-directory?forum=csharpgeneral

关于c# - 从 Active Directory c# 检索图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50287037/

相关文章:

powershell - 将PC添加到域并同时更改名称的问题

c# - 将屏幕纹理存储在 HLSL 纹理变量 (XNA) 中

python - 在 django 中使用 AuthenticationForm 不会返回任何错误

web-services - 使用 JWT 处理过期/"remember me"功能

使用组织 ID(来自同步 Azure AD)登录 Azure

c# - 如何在 Active Directory 中获取用户的组? (c#, asp.net)

java - 如何使用Java小程序来获取/重新启动服务器上运行的服务?

c# - 如何找到哪些 nuget 包包含我想要的项目

c# - 控制 LTR 和 RTL 语言之间的对齐切换

c# - SQL 和 Dapper 性能隐式转换