加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – 如何提取与Outlook正在显示的employeeID属性值相同?

发布时间:2020-12-15 19:03:06 所属栏目:asp.Net 来源:网络整理
导读:由于各种原因,我们公司使用ActiveDirectory.其中一个是处理Outlook联系人和用户登录ID. 我写了一个程序来检测登录的用户标识,并使用提取的登录ID搜索Active Directory.然后将来自Active Directory的拉出的信息存储在数据库中. 以下是我用于拉取ActiveDirecto
由于各种原因,我们公司使用ActiveDirectory.其中一个是处理Outlook联系人和用户登录ID.

我写了一个程序来检测登录的用户标识,并使用提取的登录ID搜索Active Directory.然后将来自Active Directory的拉出的信息存储在数据库中.

以下是我用于拉取ActiveDirectory信息数据的代码:

Dim enTry As DirectoryEntry = _
     New DirectoryEntry("LDAP://myCOMPANY/DC=myCOMPANY,DC=myCOMPANY,DC=com")

Dim mySearcher As DirectorySearcher = New DirectorySearcher(enTry)
mySearcher.Filter = "(&(objectClass=user)(anr=" & thisUser & "))" 
'thisUser is the variable holding the Windows ID that is accessing the ASPX page


mySearcher.PropertiesToLoad.Add("employeeID")   'just in case I need to do this.

Dim resEnt As SearchResult

Try
  For Each resEnt In mySearcher.FindAll()

  Dim fullname As String = resEnt.GetDirectoryEntry.Properties.Item("cn").Value
  'fullname will always pull the right information

  Dim e_id As String = resEnt.GetDirectoryEntry.Properties.Item("employeeID").Value
  'e_id will sometimes be NOTHING,sometimes will contain an ID that
  '   is different from the one displayed in Outlook Contact Information
  '   and sometimes it will be matching the employeeID listed in Outlook info

Catch ex as Exception
  Log("Failed to pull AD data: " & ex.Message)
End Try

由于某些原因,一些用户对于employeeID字段没有任何值,有些用户没有.

但是,在Outlook中浏览时,所有用户都将显示employeeID值.

我设计了以下图像来帮助您了解我正在经历的事情.
图像分为两个部分,每个CASE的一个部分.

================================================== ======

在案例1中,员工已使用他的ID:xms33808登录到Windows

Outlook显示他的员工ID为16078

Outlook显示他的电子邮件别名是xms33808

ASP.Net命令窗口显示他的employeeID是xms33808,这不是真的

================================================== ====

================================================== =====

在情况2中,员工已使用ID:25163登录Windows

Outlook显示他的员工ID为25163

Outlook显示他的电子邮件别名是MutawaAAB

ASP.Net命令窗口显示他的employeeID是NOTHING.

================================================== =====

我的问题是:如何解压缩Outlook显示的相同的employeeID值信息?

解决方法

有一个令人困惑的AD属性叫做“employeeNumber”.可能是Outlook实际上正在使用此属性来填充它的显示?

根据Outlook Contact Cards上的此Microsoft支持页面,“employeeID”不是您可以使用的字段.但是,’employeeNumber’是.

http://support.microsoft.com/kb/981022

希望这有助于至少提高您的故障排除工作.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读