我们公司出于各种原因使用ActiveDirectory.其中之一是处理Outlook联系人和用户登录ID.
我编写了一个程序来检测登录的用户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值.
我设计了以下图片,以帮助您了解我正在经历的事情.图像分为两个部分,每个部分都有一个部分.
================================================== ======
在案例1中,员工使用他的ID登录到Windows:xms33808
Outlook显示他的员工ID是 16078
Outlook显示他的电子邮件别名是 xms33808
ASP.Net命令窗口显示他的employeeID是xms33808
,这不是真的
================================================== ====
================================================== =====
在案例2中,员工使用ID登录Windows:25163
Outlook显示他的员工ID是 25163
Outlook显示他的电子邮件别名是 MutawaAAB
ASP.Net命令窗口显示他的employeeID是NOTHING
.
================================================== =====
我的问题是:如何提取Outlook显示的相同employeeID值信息?