Can someone please translate ms sys error code 8208 for me?

Hi,

I'm checking to see if a path is really a directory:

if (GetFileAttributes("path") != FILE_ATTRIBUTE_DIRECTORY) {
    return error;
}

But it is returning false on a particular machine, and when I call GetLastError() inside the if() it returns code 8208:

ERROR_DS_NO_RIDS_ALLOCATED
The directory service was unable to allocate a relative identifier.

What does that mean! All I want to do is check if that path is a directory!

Thanks!
LVL 3
BazookaJoeZoneAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jkrCommented:
That should be

if (GetFileAttributes("path") & FILE_ATTRIBUTE_DIRECTORY) {
   return error;
}

The value returned by 'GetFileAttributes()' is a bitmask of several attributs and is highly unlikely to contain only one single attribute.
BazookaJoeZoneAuthor Commented:
Hi jkr,

If I try that with a valid directory:

if (GetFileAttributes("C:\\I386") & FILE_ATTRIBUTE_DIRECTORY) {
    cout << "No it is not a valid directory" << endl;
}

It always appears true - if I try it with a non-existant directory it also appears true! What am I missing?

Thanks!
jkrCommented:
>>What am I missing?

The logic is reversed - it should either be

if (GetFileAttributes("C:\\I386") & FILE_ATTRIBUTE_DIRECTORY) {
   cout << "Is a valid directory" << endl;
}

or

if (!(GetFileAttributes("C:\\I386") & FILE_ATTRIBUTE_DIRECTORY)) {
   cout << "No it is not a valid directory" << endl;
}

jkrCommented:
BTW, 'GetLastError()' won't help at all in that situation, since 'GetFileAttributes()' did not fail.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BazookaJoeZoneAuthor Commented:
Hi jkr,

Oh ok I was getting confused because the check kept saying a non-existant made up directory was a valid directory! So I should do:

DWORD dwAttr = GetFileAttributes("Whatever");

// First check if the path actually exists?
if (dwAttr == 0xffffffff) {
    retun Path doesn't exist;
}

// Now check if its a directory.
if (!(dwAttr & FILE_ATTRIBUTE_DIRECTORY)) {
   return Doesn't have directory attribute!;
}

Is this proper?

Thanks!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.