AD中有存放照片的字段吗?
答案肯定是有的、photo,jpegPhoto,thumbnailPhoto

前端时间客户,包括领导 在问通讯录中的照片为什么存在数据库中而不是AD中,AD中的属性能不能利用起来呢?
我想照片这么大的数据,如果用户量大的,应该是不建议存放在AD端的,不然为什么微软的ad管理器都没有照片的管理项呢?

但是既然领导问了,当然要去验证一下。。

 1   
 2 //获取需要修改的用户对象实体
 3 private DirectoryEntry getDirectoryEntryBy(string samAccountName)
 4         { 
 5             string path="LDAP://pcdc01.company.com/OU=上海XX软件有限公司,dc=company,dc=com";
 6             DirectoryEntry rootde = new DirectoryEntry(path, "userid""pwd"); //访问用户
 7             DirectorySearcher ds = new DirectorySearcher(rootde);
 8             ds.SearchScope = SearchScope.Subtree;
 9             ds.Filter = "(&(&(objectCategory=person)(objectClass=user))(sAMAccountName=" + samAccountName + "))";
10             SearchResult sr = ds.FindOne();
11             if (sr != null)
12             {
13                return sr.GetDirectoryEntry();
14             }
15             else 
16             {
17                 return null;
18             }
19         }

 1 //以下代码是从AD中取图片 
 2 
 3 string account = this.tbAccount.Text;
 4             if ( account == "" )
 5             {
 6                 MessageBox.Show("请填写帐号");
 7                 return;
 8             }
 9             DirectoryEntry de = getDirectoryEntryBy(account);
10             if (de == null)
11             {
12                 MessageBox.Show("帐号无效");
13                 return;
14             }
15             string photocol = this.cbbPhotoCol.Text; //那个字段存取照片,三个中选一个
16             
17             System.DirectoryServices.PropertyValueCollection pvc = de.Properties[photocol];
18             if (pvc.Value != null && pvc.Value is byte[])
19             {
20                 byte[] by = (byte[])pvc.Value;
21                 MemoryStream Stream = new MemoryStream(by);
22                 this.pbcontainer.Image = Image.FromStream(Stream);
23             }
24             else
25             {
26                 MessageBox.Show("False");
27             }


 1在AD中存取照片 
 2在AD中存取照片将照片存到AD中
 3在AD中存取照片
 4在AD中存取照片string account = this.tbAccount.Text;
 5在AD中存取照片            if (account == "")
 6            }

 

出处:http://www.cnblogs.com/xuanye/archive/2008/05/13/1195225.html

AD中有存放照片的字段吗?
答案肯定是有的、photo,jpegPhoto,thumbnailPhoto

前端时间客户,包括领导 在问通讯录中的照片为什么存在数据库中而不是AD中,AD中的属性能不能利用起来呢?
我想照片这么大的数据,如果用户量大的,应该是不建议存放在AD端的,不然为什么微软的ad管理器都没有照片的管理项呢?

但是既然领导问了,当然要去验证一下。。

 1   
 2 //获取需要修改的用户对象实体
 3 private DirectoryEntry getDirectoryEntryBy(string samAccountName)
 4         { 
 5             string path="LDAP://pcdc01.company.com/OU=上海XX软件有限公司,dc=company,dc=com";
 6             DirectoryEntry rootde = new DirectoryEntry(path, "userid""pwd"); //访问用户
 7             DirectorySearcher ds = new DirectorySearcher(rootde);
 8             ds.SearchScope = SearchScope.Subtree;
 9             ds.Filter = "(&(&(objectCategory=person)(objectClass=user))(sAMAccountName=" + samAccountName + "))";
10             SearchResult sr = ds.FindOne();
11             if (sr != null)
12             {
13                return sr.GetDirectoryEntry();
14             }
15             else 
16             {
17                 return null;
18             }
19         }

 1 //以下代码是从AD中取图片 
 2 
 3 string account = this.tbAccount.Text;
 4             if ( account == "" )
 5             {
 6                 MessageBox.Show("请填写帐号");
 7                 return;
 8             }
 9             DirectoryEntry de = getDirectoryEntryBy(account);
10             if (de == null)
11             {
12                 MessageBox.Show("帐号无效");
13                 return;
14             }
15             string photocol = this.cbbPhotoCol.Text; //那个字段存取照片,三个中选一个
16             
17             System.DirectoryServices.PropertyValueCollection pvc = de.Properties[photocol];
18             if (pvc.Value != null && pvc.Value is byte[])
19             {
20                 byte[] by = (byte[])pvc.Value;
21                 MemoryStream Stream = new MemoryStream(by);
22                 this.pbcontainer.Image = Image.FromStream(Stream);
23             }
24             else
25             {
26                 MessageBox.Show("False");
27             }


 1在AD中存取照片 
 2在AD中存取照片将照片存到AD中
 3在AD中存取照片
 4在AD中存取照片string account = this.tbAccount.Text;
 5在AD中存取照片            if (account == "")
 6            }

相关文章:

  • 2022-03-08
  • 2021-11-28
  • 2022-01-14
  • 2021-11-23
  • 2021-12-23
  • 2021-08-21
  • 2022-03-06
  • 2022-12-23
猜你喜欢
  • 2021-06-19
  • 2021-06-16
  • 2022-12-23
  • 2021-09-06
  • 2022-01-15
  • 2022-12-23
相关资源
相似解决方案