Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

GP Web service security error

Posted on by 110

=======================================================

String cannot be of zero length.
Parameter name: name

  at System.Security.Principal.NTAccount..ctor(String name)
   at Microsoft.Dynamics.Security.Helper.GetSidString(String ntAccountName)
   at Microsoft.Dynamics.Security.SecurityContext..ctor()
   at Microsoft.Dynamics.Common.SecurityServiceManager.GetSecurityContext(Context context)
   at Microsoft.Dynamics.Common.SecurityServiceManager.GetRoles(Context context)
   at Microsoft.Dynamics.Common.Context.Validate(ValidationResult validationResult, Context context)
   at Microsoft.Dynamics.Common.BusinessService.GetList[DetailType,SummaryType](Criteria criteria, Context context)

========================================================

Following code(from sample) generating above error, where it went wrong? thanks a lot.

=========================================================

            string MyCompanyName;
            MyCompanyName = myComObj.GetConfigKey("Company").Trim();

            Context context;
            LikeRestrictionOfString companyRestriction;
            CompanyCriteria companyCriteria;
            Company[] MyCompany;

            // Create a context object
            context = new Context();

            // Set up the context object
            // To retrieve from the system database set the organization key to null
            context.OrganizationKey = null;
            context.CultureName = "en-US";

            // Create a restriction object to query by company ID
            // Query for all possible company ID values
            companyRestriction = new LikeRestrictionOfString();
            companyRestriction.Like = MyCompanyName ;

            // Create a company criteria object and add the restriction object
            companyCriteria = new CompanyCriteria();
            companyCriteria.Name = companyRestriction;

            // Retrieve the list of companies
            MyCompany = MyDynamicsGP.GetCompanyList(companyCriteria, context);
            return MyCompany[0].Key.Id ;
 

*This post is locked for comments

  • Gan River Profile Picture
    Gan River 110 on at
    Re: GP Web service security error

     Another run to get following error, any hint and help is appreciated.

    Microsoft.Dynamics.Common.SecurityManager.ThrowAccessDeniedException()
       at Microsoft.Dynamics.Common.SecurityManager.AssertPermission(Context context, Type type, Operation operation)
       at Microsoft.Dynamics.Common.BusinessService.GetList[DetailType,SummaryType](Criteria criteria, Context context)

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans