AD Search using the Universal API

Good morning all,

I’m trying to search for a user using an API, it doesn’t work, when the account exists it tells me that the account cannot be found.
The same code works with the Dashboard framework.

Here is the API code:

Here is the message received: (sorry in French)

image

Can you help me ?

Thank you.

Thomas.

How are you invoking the API? It looks like you might have a colon in your URL.

Are you invoking it like this?

invoke-webrequest http://localhost:5000/AfficheUtilisateur/tperez 

Hello Adam,
I invoke like this:

Regards,

Thomas

You don’t do the : in the URL for the username.

You are doing a lookup for :tperez instead of tperez

Thank you for the information, indeed I add a “:” which distorts the search.

On the other hand, I always have an error when searching for AD with the cmdlet command “Get-ADUser”.

Example Code (with Get-ADUser):

Result:

Example Code (without Get-ADUser):

Result:

Is there a known issue with adding Get-ADUser to the API? How else to fix this problem?

Thank you in advance for your help.

Thomas.

Oh, i had this issue too. A few things you can try:

Pipe the get-ADUser into a ConvertTo-JSON

If that doesn’t do the trick, try piping the get-ADUser into this and select the properties you care about:

Select Name, Mail, Description, Enabled | ConvertTo-JSON

Thank you for your return Jacob, indeed, it works with convertTo-Json as an output.
It’s a shame that we have to go through a JSON object.
Will this be corrected in the next versions?

Thank you.

Regards,

Thomas.

It does suck, but its a minor issue. Once you Run the Invoke-RestMethod and store it as a varable, it actually turns into a PSCustomObject:

ok, after analysis, the JSON conversion does not work, hence my error from the start.

When doing the steps manually, I get this error:


By translating this message into English: ConvertFrom-Json: Unable to convert the JSON string, because a dictionary converted from this string contains the duplicate keys “ObjectGuid” and “ObjectGUID”.

On the other hand, by selecting the desired parameters, it works, because there are no duplicate parameters.