|
From: Kurt B. <ku...@sd...> - 2011-11-25 14:45:44
|
Hi again,
Everything seemed all right until I choosed another (and wrongfully) password... I was still able to both login and to bind...
{code}
uses ldapsend
var
fldap:tldapsend;
fad_domain,ausername,apassword:string;
begin
ausername:='your AD username';
apassword:='your AD password';
fldap := TLDAPSend.Create;
fad_domain:= 'your.ad.domain';
fldap.TargetHost:=fad_domain;
//next line is the key to getting AD authentication working
fldap.UserName := ausername+'@'+fad_domain;
fldap.Password := apassword;
Result := fldap.Login;
If result then
begin
Result := fldap.Bind;
end;
If result then application.messagebox('Welcome','Information',mb_iconInformation+mb_ok)
else application.messagebox('Sorry!!! You are not welcome','Information',mb_iconInformation+mb_ok);
fldap.logout;
freeandnil(fldap);
end;
In VS I use:
static bool IsAuthenticated(String FQDN, String domain, String username, String pwd)
{
String domainAndUsername = (domain + @"\" + username);
String _path = "LDAP://" + FQDN;
bool Success;
DirectoryEntry entry = new DirectoryEntry(_path, domainAndUsername, pwd, AuthenticationTypes.Secure);
DirectorySearcher Searcher = new DirectorySearcher(entry);
Searcher.SearchScope = SearchScope.OneLevel;
try
{
SearchResult result = Searcher.FindOne();
Success = !(result == null);
}
catch (Exception ex)
{
Success = false;
}
return Success;
}
Where FQDN is the ip of the domainserver the username is just the username (doesn't include the domain) - and I do also use secure...
Anybody have an idea how to solve this?
All the best!
Kurt
|