IADsNameTranslate::InitEx() is failed with error code 80070057

Navaneeth R 21 Reputation points
2021-03-22T19:17:17.07+00:00

Hello, Greetings!
I'm facing issues when try to get the Canonical name of an AD object using its distinguished name. Kindly consider the below c++ snippet,

IADsNameTranslate *pNto = NULL;
HRESULT hr = pNto->InitEx( ADS_NAME_INITTYPE_SERVER ,serverName ,user ,domain ,password);

I receive the error code 80070057 (ERROR_INVALID_PARAMETER) when I provide the IP address of the Domain Controller to 'serverName'.
If I provide the Domain Controller's hostname instead of IP address, it will work without any issues.

Ex:
If I call the InitEx method like:

pNto->InitEx( ADS_NAME_INITTYPE_SERVER ,L"192.168.0.1",username ,domain ,password);

then the InitEx method throws "80070057".

If I call the InitEx method like:

pNto->InitEx( ADS_NAME_INITTYPE_SERVER ,L"mydcserver",username ,domain ,password);

then the InitEx succeeds.

For some reasons, we couldn't provide the domain controller's hostname.

FYI: I'm using the domain admin credentials

And my questions are,

  1. Why it is failing when we use IP address?
  2. Is it possible to get the canonical name of an AD object using the domain controller's IP address instead of hostname?

Thanks!

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
13,577 questions
Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
6,810 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Fan Fan 15,361 Reputation points Microsoft Vendor
    2021-03-23T00:57:05.69+00:00

    Hi,
    Welcome to share here!

    Where did you try to run the code?
    I'm afraid i can't give more advice about the c++ snippet.
    Scripts to get the Canonical name in the following link for your reference:
    https://community.spiceworks.com/topic/2203273-list-all-users-in-ad-to-include-canonical-name-powershell
    https://serverfault.com/questions/576497/active-directory-user-names-why-does-the-canonical-name-vary-can-i-do-somethin

    This response contains a third-party link. We provide this link for easy reference. Microsoft cannot guarantee the validity of any information and content in this link.

    Best Regards,

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.