question

NavaneethR-8522 avatar image
0 Votes"
NavaneethR-8522 asked NavaneethR-8522 edited

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

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-serverwindows-active-directory
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

FanFan-MSFT avatar image
0 Votes"
FanFan-MSFT answered

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,

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.