Delphi如何从活动目录中提取特定用户的电子邮件地址?

更新于
2026-10-04 21:32:26
1阅读来源:SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计299个文字,预计阅读时间需要2分钟。

我在尝试通过Active Directory使用sAMAccountName获取用户电子邮件地址时,收到了错误消息:在缓存中找不到目录属性。虽然我能够获取到全名、部门和自由裁量权权限,但为什么我无法收到正确的信息呢?

我试图通过使用Active Directory中的sAMAccountName来获取用户的电子邮件地址,但我收到此错误消息:

The directory property cannot be found in the cache.

我可以获得全名,部门和自由裁量权,但为什么我收到电子邮件的错误?

uses ActiveDs_TLB, adshlp; procedure TMainForm.btnFillInfoClick(Sender: TObject); var Usr: IAdsUser; lStr: HRESULT; xStrg: string; ChkPRN: string; RemoveDot: string; begin //connect to AD and try exrtact the info / lStr := ADsGetObject('WinNT://10.120.200.16/'+edtPRN.Text, IADsUser, usr); // edtPRN.Text >> sAMAccountName if Succeeded(lStr) then begin Usr.GetInfo; EmpFullName := Usr.FullName; RemoveDot := StringReplace(EmpFullName, '.', '',[rfReplaceAll, rfIgnoreCase]); xStrg := Usr.FullName; edtLastName.Text := GetLastWord(xStrg); xStrg := StringReplace(RemoveDot, edtLastName.Text, '',[rfReplaceAll, rfIgnoreCase]); EdtMidName.Text := GetLastWord(xStrg); xStrg := StringReplace(RemoveDot, EdtMidName.Text, '',[rfReplaceAll, rfIgnoreCase]); xStrg := StringReplace(xStrg, edtLastName.Text, '',[rfReplaceAll, rfIgnoreCase]); edtFirstName.Text := GetLastWord(xStrg); edtEmail.Text := Usr.EmailAddress; // <<<<< this is the error end; end; 使用WinNT://提供程序无法使用电子邮件地址属性,您需要使用LDAP://提供程序.该属性的名称是’mail’而不是’emailaddress’.这是ASDI和Delphi的链接. ASDI examples.

本文共计299个文字,预计阅读时间需要2分钟。

我在尝试通过Active Directory使用sAMAccountName获取用户电子邮件地址时,收到了错误消息:在缓存中找不到目录属性。虽然我能够获取到全名、部门和自由裁量权权限,但为什么我无法收到正确的信息呢?

我试图通过使用Active Directory中的sAMAccountName来获取用户的电子邮件地址,但我收到此错误消息:

The directory property cannot be found in the cache.

我可以获得全名,部门和自由裁量权,但为什么我收到电子邮件的错误?

uses ActiveDs_TLB, adshlp; procedure TMainForm.btnFillInfoClick(Sender: TObject); var Usr: IAdsUser; lStr: HRESULT; xStrg: string; ChkPRN: string; RemoveDot: string; begin //connect to AD and try exrtact the info / lStr := ADsGetObject('WinNT://10.120.200.16/'+edtPRN.Text, IADsUser, usr); // edtPRN.Text >> sAMAccountName if Succeeded(lStr) then begin Usr.GetInfo; EmpFullName := Usr.FullName; RemoveDot := StringReplace(EmpFullName, '.', '',[rfReplaceAll, rfIgnoreCase]); xStrg := Usr.FullName; edtLastName.Text := GetLastWord(xStrg); xStrg := StringReplace(RemoveDot, edtLastName.Text, '',[rfReplaceAll, rfIgnoreCase]); EdtMidName.Text := GetLastWord(xStrg); xStrg := StringReplace(RemoveDot, EdtMidName.Text, '',[rfReplaceAll, rfIgnoreCase]); xStrg := StringReplace(xStrg, edtLastName.Text, '',[rfReplaceAll, rfIgnoreCase]); edtFirstName.Text := GetLastWord(xStrg); edtEmail.Text := Usr.EmailAddress; // <<<<< this is the error end; end; 使用WinNT://提供程序无法使用电子邮件地址属性,您需要使用LDAP://提供程序.该属性的名称是’mail’而不是’emailaddress’.这是ASDI和Delphi的链接. ASDI examples.