Delphi如何从活动目录中查询用户的电子邮件地址?

2026-04-10 17:572阅读0评论SEO问题
  • 内容介绍
  • 文章标签
  • 相关推荐

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

Delphi如何从活动目录中查询用户的电子邮件地址?

我尝试通过使用Active Directory中的sAMAccountName获取用户的电子邮件地址,但收到错误信息:The directory property cannot be found in the cache. 我可以获取到全名、部门和自由裁量权,但为什么我收到的却是错误的?

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

Delphi如何从活动目录中查询用户的电子邮件地址?

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.

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

Delphi如何从活动目录中查询用户的电子邮件地址?

我尝试通过使用Active Directory中的sAMAccountName获取用户的电子邮件地址,但收到错误信息:The directory property cannot be found in the cache. 我可以获取到全名、部门和自由裁量权,但为什么我收到的却是错误的?

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

Delphi如何从活动目录中查询用户的电子邮件地址?

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.