Re: LDAP user authentication error with VBScript from ASP



That error means "the specified domain could not be contacted". That
usually happens when ADSI doesn't have enough information to figure out
which domain to use.

Since you are doing a serverless bind to the directory in your first call
(LDAP://rootDSE), ADSI tries to pick up the domain to use based on the
current security context of the executing thread. In ASP, impersonation is
always used. Since this code is probably running as anonymous (since the
code is performing authentication, I'm guessing the page itself did not use
Windows auth), it will impersonate the anonymous user. That user is
typically NOT a domain user, so it has no domain affiliation and thus the
ADSI code has this error.

You can usually get around this by supplying the DNS domain name of the
domain:

LDAP://domain.com/rootDSE

Also, I think you might be better off if your code skipped the bit with the
rootDomainNamingContext and just did this:

Set objDSObj = GetObject("LDAP:")
Set objAuth = objDSObj.OpenDSObject("LDAP://domain.com/rootDSE";,
strDomainUser, strPassword, 1)

It is fine to use RootDSE as your target here and actually has a few
benefits in doing so.

In general, if the machine itself is domain joined, I'd suggest using
Windows authentication instead of forms auth in the first place. Windows
auth allows you to avoid this mess and will give you better scalability. If
you can't use IWA, you can use Basic auth. Basic auth essentially requires
you to use SSL, but you can't do forms auth like this securely without SSL
anyway (you weren't trying to, were you?), so you might as well just switch.
That's my $0.02.

..NET S.DS and ADSI go through the exact same code and have the same behavior
characteristics for the most part, so if the .NET code is working but your
script code isn't, it is likely because you are using slightly different
parameters or your operational parameters are slightly different.

HTH,

Joe K.
--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
"mirin" <zenstory@xxxxxxxxx> wrote in message
news:1188549604.881156.228070@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,

I've been using the below code in my ASP page to authenticate users
against the Active Directory.
The code was working well but recently started throwing 'error
8007054b'. I search the net and understand that this could be due to
some security or network issue. The server guys say they havent
changed anything. I have another ASP.NET 2.0 application which is
working fine to authenticate users with System.DirectoryServices but
am stuck with the legacy ASP application breaking at ect("LDAP://
rootDSE")

Also the Active Directory maintenenace guys say that the server was
never marked as "Trust this computer for delegation" even when the
code was working so this doesnt seem to be a problem either.

Here's the relevant code:

strDomainUser = strDomain & "\" & strUserId
Set objRootDSE = GetObject("LDAP://rootDSE";)
strADSPath = objRootDSE.Get("rootDomainNamingContext")
Set objDSObj = GetObject("LDAP:")
Set objAuth = objDSObj.OpenDSObject("LDAP://"; & strADSPath,
strDomainUser, strPassword, 1)

Much appreciate any advice on this.

Best Regards,
mirin



.



Relevant Pages

  • Re: LDAP user authentication error with VBScript from ASP
    ... On Aug 31, 11:46 pm, "Joe Kaplan" ... ADSI code has this error. ... Windows authentication instead of forms auth in the first place. ...
    (microsoft.public.windows.server.active_directory)
  • Re: ADFS app dev and org claim group mappings not working
    ... "Joe Kaplan" wrote: ... Co-author of "The .NET Developer's Guide to Directory Services Programming" ... I posted this in ADSI forum too because I just noticed a lot of ADFS ...
    (microsoft.public.windows.server.active_directory)
  • Re: Principal flowing and caching
    ... You could use Basic authentication instead of forms auth if you want to ... Regarding caching the WindowsIdentity, as long as you keep it in memory, it ... Co-author of "The .NET Developer's Guide to Directory Services Programming" ... Is it possible to cache the Kerberos Principal ??... ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Authentication? Forms without Anynymous access
    ... If you want to keep using that system and forms auth, ... If you really want to use Windows auth, then you can still do role-based ... If your app needs to authenticate users ... >> If the need is for your app to authenticate users in the domain, ...
    (microsoft.public.dotnet.security)
  • Re: How to Resolve SID(SSDL) to UPN or DomainUserId or GUID via ADSI
    ... Joe Kaplan-MS MVP Directory Services Programming ... Co-author of "The .NET Developer's Guide to Directory Services Programming" ... I want to convert SSDL to other type formatvia ADSI. ...
    (microsoft.public.windows.server.active_directory)