Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Why is Dynamics GP WebService returning: Security object does not exist. Key = 0 for a companykey ID set as (-1)

(0) ShareShare
ReportReport
Posted on by 35

Hi,

I have this issue trying to integrate a web application with Dynamics GP. I have followed the documentation for doing that but it returns an error. Going through the MicrosoftDynamicsWebServiceException Console reveals "Security object does not exist.  Key = 0" as the error, which means that there was communication with GP service but there is no company with key 0. I have gone through a lot of blogs including this community but the recommendations are not giving any solution, also I found no response that resolved the issue. I also came accross this popular response: https://mbs.microsoft.com/knowledgebase/KBDisplay.aspx?WTNTZSMNWUKNTMMYVLXUZLWUKKQPOVRVTLKUSRMOQVVYUKKXRVYRTTWLZTPWKURU to no avail. 

NB: I am not using ADAM for storage and the SQL check for company id returns the right ID (-1).  I'm running in a domain environment within a development machine.

The XML request is as follows:

<?xml version="1.0"?>
<RequestObjects>
  <Context xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/dynamics/2006/01">
    <OrganizationKey xsi:type="CompanyKey">
      <Id>0</Id>
    </OrganizationKey>
    <CurrencyType>Transactional</CurrencyType>
    <TenantName />
  </Context>
  <GLAccountCriteria xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <IsActive>
      <EqualValue xsi:nil="true" />
      <NotEqualValue xsi:nil="true" />
    </IsActive>
  </GLAccountCriteria>

</RequestObjects>

 

while my code is:

        Dim companyKey As CompanyKey
        Dim context As Context
        Dim GLAccountSummaryList() As GLAccountSummary
        Dim GLAccountCriteria As GLAccountCriteria
        Dim accountActiveRestriction As RestrictionOfNullableOfboolean

        ' Create an instance of the service
        Dim wsDynamicsGP As New DynamicsGPClient()

        ' Create a context with which to call the service
        context = New Context()

        ' Specify which company to use (sample company)
        companyKey = New CompanyKey()
        companyKey.Id = (-1)

        ' Set up the context
        context.OrganizationKey = CType(companyKey, OrganizationKey)
        'context.OrganizationKey = Nothing

        ' Set the criteria specifying wich accounts to retrieve
        GLAccountCriteria = New GLAccountCriteria()
        accountActiveRestriction = New RestrictionOfNullableOfboolean()
        accountActiveRestriction.EqualValue = True
        GLAccountCriteria.IsActive = accountActiveRestriction

        ' Retrieve the list of active accounts
        GLAccountSummaryList = wsDynamicsGP.GetGLAccountList(GLAccountCriteria, context)


        ' Display the total number of active accounts
        Dim message = New message
        message.ShowAlert(Me, "Total active accounts:" & GLAccountSummaryList.Length.ToString())

        ' Close the service
        If wsDynamicsGP.State <> CommunicationState.Faulted Then
            wsDynamicsGP.Close()
        End If

WebConfig:

  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="GPWebService" closeTimeout="00:01:00" openTimeout="00:01:00"
          receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
          transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
          messageEncoding="Text" proxyAddress="http://localhost:2000"
          textEncoding="utf-8" useDefaultWebProxy="false" allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="2147483647" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
            enabled="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
              algorithmSuite="Default" establishSecurityContext="true" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://SERVERNAME:48620/Dynamics/GPService/GPService"
        binding="wsHttpBinding" bindingConfiguration="GPWebService"
        contract="DynamicsGPService.DynamicsGP" name="GPWebService">
        <identity>
          <userPrincipalName value="Domain\UserID" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>

I've been on this for a week now

Please help......

Thanks

*This post is locked for comments

  • Olufemi Ogunlolu Profile Picture
    35 on at
    RE: Why is Dynamics GP WebService returning: Security object does not exist. Key = 0 for a companykey ID set as (-1)

    Thanks Somakarpagamoorthy,

    The first link you post is the same as the the one in my first post. I have gone through the steps:

    1. "Select INTERID as [Database Name], CMPANYID as [Scope Key] From SY01500" returns the right ID.

    2. I'm not using ADAM for Authorization Store.

    3. I have carried out this step more twice. Still no resolution.

    NB: Running the code below returns the number of companies in GP (I believe it works because its retrieving the information from Dynamics Database).

               ' Create an instance of the service

               Dim wsDynamicsGP As New DynamicsGPClient()

               ' Create a restriction object to query by company ID

               ' Query for all possible company ID values

               companyRestriction = New BetweenRestrictionOfNullableOfint()

              companyRestriction.From = -32768

               companyRestriction.To = 32767

               ' Create a company criteria object and add the restriction object

               companyCriteria = New CompanyCriteria()

               companyCriteria.Id = companyRestriction

               ' Retrieve the list of companies

               companyList = wsDynamicsGP.GetCompanyList(companyCriteria, context)

     

    Any other idea where the issue could be?

    Thanks!

  • Suggested answer
    soma Profile Picture
    24,410 on at
    RE: Why is Dynamics GP WebService returning: Security object does not exist. Key = 0 for a companykey ID set as (-1)

    Please have a look on the below links.

    support.microsoft.com/.../943949

    community.dynamics.com/.../109765.aspx

    Hope this helps!!!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

#1
Almas Mahfooz Profile Picture

Almas Mahfooz 3 User Group Leader

Featured topics

Product updates

Dynamics 365 release plans