由于各种原因,我们公司使用ActiveDirectory。其中之一是处理Outlook联系人和用户登录ID。如何提取Outlook正在显示的相同employeeID属性值?
我写了一个程序来检测登录的用户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
出于某种原因,一些用户没有值的雇员ID字段,以及一些有。
但是,所有用户将在Outlook中浏览时显示employeeID值。
我设计了以下图像以帮助您了解我正在经历什么。 该图像分为两个部分,每个CASE部分。
============================================== ==========
在案例1,员工使用自己的ID已经登录到Windows:xms33808
展望表明,他的员工ID为16078
展望显示他的电子邮件别名是xms33808
ASP.Net命令窗口中显示,他的员工ID为xms33808
,这是不正确
====================================== ================
============================== =========================
在案例2中,员工使用ID已经登录到Windows:25163
展望表明,他的雇员ID 25163
Outlook显示他的电子邮件别名是MutawaAAB
ASP.Net命令窗口显示他的员工ID是NOTHING
。
============================================== =========
我的问题是:我怎样才能提取相同的雇员价值信息Outlook正在显示?
很奇怪 - 你没有辅助AD服务器吗? –
@DarkcatStudios号只有一个AD服务器。但是我怎样才能检查是否有另一个?我的意思是没有通过IT人为干预? – Ahmad