我试图通过使用Active Directory中的sAMAccountName来获取用户的电子邮件地址,但我收到此错误消息: The directory property cannot be found in the cache. 我可以获得全名,部门和自由裁量权,但为什么我收
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.