Skip to main content
Nintex Community Menu Bar

Error while executing SAP method 'no credentials cached for this label'

  • September 3, 2009
  • 4 replies
  • 14 views

Forum|alt.badge.img+4

 I m trying to execute one SAP method through code.


But while execution it gives an error like "'no credentials cached for this label'".


So, I have provided  SAP  credentials from method but still it gives an error.


Is anyone aware of this issue?


Response will be appreciated..


Thanks,


Sush...

4 replies

Forum|alt.badge.img
  • September 3, 2009

Hi Sush


 


Below is a sample console application that tries to execute a SmartObject using the current user's credentials.


If the credentials aren't cached it will raise an AuthenticationException and will prompt for new credentials (in your case the SAP credentials)


hth 


 


using System;


using System.Collections.Generic;


using System.Text;


 


namespace TestAuthentication


{


    class Program


    {


        static void Main(string[] args)


        {


            try


            {


                ExecuteListSmartObject("Account", "GetList");


            }


            catch (Exception ex)


            {


                Console.WriteLine("ERROR: {0}", ex.Message);


            }


            finally


            {


                Console.WriteLine("Press any key to continue ...");


                Console.ReadKey();


            }


        }


 


        static void ExecuteListSmartObject(string smartObjectName, string methodToExecute)


        {


            SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder scConnectionStringBuilder =


                new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();


            scConnectionStringBuilder.Host = "localhost";


            scConnectionStringBuilder.Port = 5555;


            scConnectionStringBuilder.IsPrimaryLogin = true;


            scConnectionStringBuilder.Integrated = true;


 


            SourceCode.SmartObjects.Client.SmartObjectClientServer clientServer =


                new SourceCode.SmartObjects.Client.SmartObjectClientServer();


            clientServer.CreateConnection();


            clientServer.Connection.Open(scConnectionStringBuilder.ConnectionString);


 


            SourceCode.SmartObjects.Client.SmartObject smartObject = clientServer.GetSmartObject(smartObjectName);


            smartObject.MethodToExecute = methodToExecute;


 


            bool tryAgain = true;


 


            while (tryAgain)


            {


                tryAgain = false;


                try


                {


                    SourceCode.SmartObjects.Client.SmartObjectList listResult = clientServer.ExecuteList(smartObject);


                    Console.WriteLine("Successful");


                    tryAgain = false;


                }


                catch (SourceCode.Hosting.Exceptions.AuthenticationException authEx)


                {


                    // User to supply Authentication details


                    if (AddProvideAuthentication(authEx, clientServer))


                    {


                        tryAgain = true;


                    }


                }


            }


        }


 


        static bool AddProvideAuthentication(SourceCode.Hosting.Exceptions.AuthenticationException authEx,


            SourceCode.SmartObjects.Client.SmartObjectClientServer clientServer)


        {


            // Get UserName


            Console.WriteLine(string.Format("Provide UserName for {0}", authEx.ProviderFriendlyName));


            string userName = Console.ReadLine();


 


            if (string.IsNullOrEmpty(userName))


            {


                return false;


            }


 


            // Get Password


            Console.WriteLine(string.Format("Provide Password for {0}", authEx.ProviderFriendlyName));


            string password = Console.ReadLine();


 


            if (string.IsNullOrEmpty(password))


            {


                return false;


            }


 


            // Apply Authentication to current SmartObjectClientServer


            SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder conn =


                new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder(clientServer.Connection.ToString());


            conn.IsPrimaryLogin = false;


            conn.Integrated = false;


            conn.SecurityLabelName = authEx.ProviderFriendlyName;


            conn.UserID = userName;


            conn.Password = password;


            conn.AuthData = authEx.ProviderFriendlyName;


 


            clientServer.Connection.Authenticate(conn.ConnectionString);


            return true;


        }


    }


}


Forum|alt.badge.img+4
  • Author
  • September 4, 2009

Thanks Schalk for ur reply..


I will try this solution..


 


Forum|alt.badge.img+4
  • Author
  • October 12, 2009

Hi Schalk,


It worked for me..


Thanks..


 


Forum|alt.badge.img

Hi Schalk,


I have the same problem, after creating your consol appication still give me the same error 'no credentials cached for this label'


i think the provided credentials (username|password) is the problem, but i am using this credentials when i connect to SAP Destination "by checking predefined credentials checkbox". i am confused :S:S how i can ensure that the credentials is correct