ADsGetObject() fails with HR = 0x800401e4 (Invalid Syntax)

C

Chuck Chopp

I have some C++ code that has been working just fine for looking up
group type & group membership information for the past 3 years. It
calls ADsGetObject() to bind to the group object using an LDAP URL as
follows:

"LDAP://CN=NSMAdmins,CN=Users,DC=w2k3ee,DC=local"

The interface being requested is IID_IDirectoryObject.

This was working fine when the code was built using the WinXP Platform
SDK on a WinXP Pro SP2 system running MS Visual Studio 2003 .NET.

Recently, I had to recompile the application on Vista Ultimate x64 SP1
[targeting a 32-bit x86 platform] using Visual Studio 2008 with the
latest Microsoft Platform SDK v6.1. After doing a "clean" and then a
"build", with no errors and only a few harmless warnings about usage of
a deprecated strcpy() function, I ran the code to test it. Without
having made any actual changes to the code, it no longer runs properly
and ADsGetObject() is failing with an HRESULT value of 0x800401e4, which
is documented as meaning "Invalid Syntax", but for which no other
reference material seems to exist.

I'm running the code on a Win2K3 EE R2 x64 SP2 system. Previous builds
of the application still run OK on this system, it's only the newer
build that fails in this way.

Has anybody else run across this problem before? Is there an online
reference that provides info for diagnosing this problem?
 
J

Joe Kaplan

This error code is pretty low level and isn't something coming out of the
LDAP level (those are all 8005xxxx HRs), so I'm guessing you have a problem
in the guts of COM with something like a missing include or library. I have
no idea what it is that you are missing though.

Good luck finding it!

Joe K.
 
C

Chuck Chopp

Joe said:
This error code is pretty low level and isn't something coming out of the
LDAP level (those are all 8005xxxx HRs), so I'm guessing you have a problem
in the guts of COM with something like a missing include or library. I have
no idea what it is that you are missing though.

Good luck finding it!

Joe K.


Yeah, that's what I began to suspect. I went back and re-examined all
of the source modules and headers and found out that a header file that
is now considered "cross-platform", which is being used in projects
built on both Windows and Linux, had the call to CoInitialize()
improperly wrapped up in a "#ifdef" block. It was in a routine that is
used during thread initialization, and COM simply wasn't being
intiailized, thus all of the ADs*() functions were failing.

I did end up finding this article, though that explains about this
misleading error code being returned:

http://support.microsoft.com/kb/171724/en-us

The problem has been remedied....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top