Invoke-NAVCodeunit - The server has rejected the client credentials

BarthoBartho Member Posts: 6
Hi,

I am in the process of creating a NAV test enviroment using PowerShell and need to run several codeunits with PowerShell.

However when I run Invoke-NAVCodeunit I get an error message saying "The server has rejected the client credentials". As far as I can see Invoke-NAVCodeunit doesn't accept any credential parameters.

The ClientServicesCredentialType on the server instance is set to NavUserPassword. If I delete all users in the database then I am able to run Invoke-NAVCodeunit without any errors however I cannot delete the users as the codeunits I am running requires users to be present.

Any ideas how to solve this?

Thanks,
Morten

Answers

  • allenyyzhouallenyyzhou Member Posts: 142
    Hi,

    First, you need to make sure you can login RTC use that user(with user created in NAV), if so, then I think the way you pass user id and password to NAV through powershell is not correct.
    You can paste the command here, someone else can help you with that.
  • BarthoBartho Member Posts: 6
    Hi,

    First, you need to make sure you can login RTC use that user(with user created in NAV), if so, then I think the way you pass user id and password to NAV through powershell is not correct.
    You can paste the command here, someone else can help you with that.

    I can logon with RTC without any problems.

    To run the codeunit from PowerShell I use the command below.

    Invoke-NAVCodeunit -CompanyName "CRONUS International Ltd." -CodeunitId 50000 -ServerInstance NAV
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    How exacly do you pass your credentials in Invoke-NAVCodeunit call? I haven't seen anyting in the documentation saying that you can do it.

    If you do not pass anyting explicitely then I'd assume that Invoke-NAVCodeunit uses your windows credentials to log in, an in order to make it work you need to have a separate NST handling Windows authentication, as NST does not support mixed authentication types.
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • BarthoBartho Member Posts: 6
    The solution was simply to create a new user (Windows authentication) and permission set for the Windows user running PowerShell. After creating this user I was able to run the codeunit. There is no need to create a separate NST handling Windows authentication.
Sign In or Register to comment.