ADSI Authentication.
All,
I have been going nuts over this.
There are many snippets of code around and different approaches all with
different performance/issues, firewall ports/requirements.
Here is what I found, but it's sometimes VERY slow, and I am talking in the
order of 10 seconds:
Keep in mind I see NO CPU usage, it;s against a BRAND NEW 2003 ent server/ad
in 'no backward compatible mode'.
this is all because I want to work with a pure and possibly dmz/secure
scenario with only 389TCP port open.
some other times (rarely) this call can take only a fraction of a second,
and this is totally random, the same code run a few hours later.
I've seen this in different cases, keep in mind this code WORKS!!! and the
reason why I am requesting the search interface, is because I want to
authenticate
making sure the given user also is ENABLED/NOT LOCKED, this was the only way
that I know but maybe not correct.
Keep in mind in my scenario I am keeping the two computer's firewalls off,
with exceptions for 389TCP only on the ad server.
Ultimately what should I do instead ?
All I need is using ADSI, to authenticate against an AD server, where I only
need 389 open, I want to address the server by address[:port].
Please help, I could never find anything that can help me, and this question
of mine is so common, that could help everyone else.
Thank you.
HRESULT hResult;
WCHAR Username[] = L"myuser";
WCHAR Password[] = L"mypassword";
WCHAR LDAPAddress[] = L"LDAP://192.168.1.100:389";
if ( (hResult = ADsOpenObject(LDAPAddress, Username, Password,
ADS_SECURE_AUTHENTICATION | ADS_USE_SEALING, IID_IDirectorySearch,
(void**)&pDS)) == S_OK ) {
iReturn = AUTHENTICATION_RETURN_OK;
}
else {
iReturn = AUTHENTICATION_RETURN_ERROR;
}
date: Fri, 6 May 2005 10:45:19 -0700
author: andrea catto