Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2006 Dec : Using Active Directory to get a users email address
| Subject: | Using Active Directory to get a users email address |
| Posted by: | "Colin" (col..@opms.com.au) |
| Date: | Fri, 1 Dec 2006 08:10:00 |
Hi
I am using the following code to try and get an email address from Active
Directory. But I get an error. I can set a password and change a password,
but I cannot get an email address. Any idea what I am doing wrong?
(Domain.Text and User.Text are text boxes where I enter the Domain name and
the userID).
var
EObj:IADsUser;
begin
try
Screen.Cursor:=crHourglass;
CoInitialize(nil);
EObj:= GetObject('WinNT://'+Domain.Text+'/'+UserID.Text+',user') as
IADsUser;
try
//EObj.setPassword(edit3.text); //this works fine
//EObj.ChangePassword('Bill','Colin'); //this works fine
showmessage(EObj.EMailAddress); //this throws an error "The
directory property cannot be found in the cache"
except
MessageBeep(mb_ICONEXCLAMATION);
Application.MessageBox('Email Address Failed
!','Authenticated',mb_OK + mb_ICONINFORMATION);
end;
finally
CoUninitialize;
end;
end;