由于各种原因,我们公司使用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
ASP.Net命令窗口显示他的employeeID是xms33808,这不是真的
================================================== ====
================================================== =====
在情况2中,员工已使用ID:25163登录Windows
Outlook显示他的员工ID为25163
ASP.Net命令窗口显示他的employeeID是NOTHING.
================================================== =====
我的问题是:如何解压缩Outlook显示的相同的employeeID值信息?