New Posts New Posts RSS Feed: No Credentials Supplied
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

No Credentials Supplied

 Post Reply Post Reply
Author
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Topic: No Credentials Supplied
    Posted: 26-Jun-2013 at 5:27pm
I am calling a Remote Server Method. Here is the call.
 
        public void SetPacAnd401KBenefits(string socSecNo, Int32 refNo)
        {
            string typeName = "UnionAdministratorWeb.Services.MemberService, UnionAdministratorWeb";
            string methodName = "SetPacAnd401KBenefits";
            Manager.InvokeServerMethod(typeName, methodName, new object[] {socSecNo, refNo});                  
        }
and the start of the Remote Server Method
       public static void SetPacAnd401KBenefits(IPrincipal principal, EntityManager entityManager, params Object[] args)
        {
            _entityManager = entityManager;
 
            string socSecNo = (string) args[0];
            Int32 refNo = (Int32)args[1];
 
When I run my app as a 2 tier app setting (the IsDistributed equals false) the server medthod works just fine.
 When i changed the setting to true and use the BOS which is located on a server which i am connected to by a vpn i can 
login into the app, access my data and everything is fine until I call the remote server method then i get an
System.ServiceModel.FaultException. "No credentials supplied"
Here is the last entry in the Debug.log from the BOS

Caught exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> IdeaBlade.EntityModel.LoginException: No credentials supplied at IdeaBlade.EntityModel.EntityManager.HandleEntityServerException(Exception ex, Boolean tryToHandle, PersistenceOperation operation, Boolean throwOnError) at IdeaBlade.EntityModel.EntityManager.LoginCore(Func`1 loginFunc) at IdeaBlade.EntityModel.EntityManager.ExecuteFetch(IEntityFinder finder) at IdeaBlade.EntityModel.EntityManager.ExecuteQueryCore(IEntityQuery query, Boolean isAsync) at IdeaBlade.EntityModel.EntityManager.ExecuteQuery(IEntityQuery query) at UnionAdministratorWeb.Services.MemberService.DeleteJHBenefits(Int32 refNo, String component) at UnionAdministratorWeb.Services.MemberService.SetPacAnd401KBenefits(Int32 refNo) --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at IdeaBlade.EntityModel.Server.EntityServer.InvokeServerMethod(SessionBundle sessionBundle, ITypeWrapper entityManagerType, String typeName, String methodName, Object[] args) at SyncInvokeInvokeServerMethod(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

If i RDP into the server where the BOS and database are running, the same thing happens. It only works running as a 2 tier app.
 
Any suggestions.
Bill
 
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jun-2013 at 5:04pm
The Remote Server Method uses the same security context as your queries to the BOS, so it's not clear why the BOS is going through the login again. Are you creating another EntityManager in your service method, other than what you show here?
Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jun-2013 at 5:09pm
no i just assign the incoming EntityManager to a local copy of it for use in the server method. It is strange the server methods work just fine if i am not using the BOS. could it be something in the setup of my BOS. But when i use the BOS i can connect just fine to the database and everything works fine until it comes to an InvokeServerMethod call.
 
 
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jun-2013 at 5:25pm
It is strange. Which specific version of DevForce are you running?
Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jun-2013 at 5:25pm
6.1.13 Devforce 2010
Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jun-2013 at 5:34pm
could it be a domain issue? I am trying to run it either through a VPN or by RDP on the server. I am not a part of the domain in either case am I? Could the BOS have a problem with that? Yet it lets me log in ok to the sql server when using the BOS. The only issue is when trying to access a remote server method. Yet the Remote Server Method works fine when running it as a 2 tier app. it is only when accessing the Remote Server Method using the BOS that i get the No Credentials Supplied exception
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jun-2013 at 5:55pm
Just to be clear, a login to the EntityManager or Authenticator is not the same as a database login. The database login always uses the connection string information. DevForce uses your IEntityLoginManager-supplied information to set its authentication context.

When you use a "server side" EntityManager, which is what you're provided in the RSM, that EM is already considered logged in, so DevForce should not be attempting to re-validate credentials.

The BOS is multi-threaded, so you need to make sure that your service methods are too. I notice you're holding the EntityManager in a static variable, that could definitely cause other problems, and might be causing the problem here too. For one, the EM is not threadsafe, but it's also possible that this variable was assigned previously and maybe its authentication context has gone out of scope. Anyway, I'd first try this without the static EM to see if that helps. You can also add your own DebugFns or TraceFns calls within the service methods to get some more diagnostics.
Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jun-2013 at 5:58pm
I just reran tests again. If i run the app without the BOS as a 2 tier app, the remote server methods get called and the app runs fine. If i run the app using the BOS the app crashes at the InvokeServerMethodCall.
Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jun-2013 at 6:25pm
ok this is now interesting. I tried a different situation. I ran it through the BOS again. This time I made a call to a different Remote  Server Method right before the one that failed and that one worked. there was no exception. The Remote Server Method executed correctly and returned the correct value. It then tried to execute the problem Remote Server Method and I got the execption. No Credential Found.
 
Here are the two calls
 
       public Int32 GetCurrentJobRefNo(string socSecNo)            // this remote method server call worked fine
        {
            string typeName = "UnionAdministratorWeb.Services.MemberService, UnionAdministratorWeb";
            string methodName = "GetCurrentJobRefNo";
            Int32 refNo = (Int32)Manager.InvokeServerMethod(typeName, methodName, socSecNo);
            return refNo;
        }
 
     public void SetPacAnd401KBenefits(string socSecNo, Int32 refNo)
          {
            string typeName = "UnionAdministratorWeb.Services.MemberService, UnionAdministratorWeb";
            string methodName = "SetPacAnd401KBenefits";
            Manager.InvokeServerMethod(typeName, methodName, new object[] {socSecNo, refNo});                  
        }
 
Here are the Remote Server Methods
      private static EntityManager _entityManager;
      [AllowRpc]
        public static Int32 GetCurrentJobRefNo(IPrincipal principal, EntityManager entityManager, params Object[] args)
        {
            _entityManager = entityManager;
            var socSecNo = (string)args[0];
  
            GetMember(socSecNo);
 
            Int32 refNo = GetCurrentJobRefNo();
 
            return refNo;
        }
       [AllowRpc]
        public static void SetPacAnd401KBenefits(IPrincipal principal, EntityManager entityManager, params Object[] args)
        {
            _entityManager = entityManager;
 
            string socSecNo = (string) args[0];
            Int32 refNo = (Int32)args[1];
 
            GetMember(socSecNo);
 
            SetPacAnd401KBenefits(refNo);
 
        }
 
Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jun-2013 at 6:42pm
but the entityManager has to be static. My server side methods are static and they cannot access a non static variable.
Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jun-2013 at 7:02pm
I found the problem. It was so stupid on my part. But i don't know how to fix it. I am trying to call a stored procedure from the my server method. It is that call that is causing the problem.
       public static void InsertJHBenefits(Int32 refNo, string component, Decimal? amount)
        {
            var eml = new UnionEntities();
            var query = eml.UA_SP_InsertJHBenefitsQuery(refNo, component, amount);
            eml.ExecuteQuery(query);
        }
 
I foolishly created a new EntityManager and that one has not be authenticated.
 But how do i call a stored procedure using the current _entityManager that I have.
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 29-Jun-2013 at 6:50am
The EntityManager passed into the remote service method is actually a sub-typed EM, so you can cast to your custom EM type.   A better approach though is to use the EM copy constructor.
 
// 1 - cast
var em2 = EntityManager as UnionEntities;
 
// 2 ctor
var em2 = new UnionEntities(EntityManager);
 
You should still avoid the static _entityManager variable.  This is going to cause you later problems as you move into production and your BOS is under more load.  Instead of holding onto a variable, pass the EntityManager as a parameter to your helper methods.
 
Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 29-Jun-2013 at 7:14am
thank you for all your help. About 3 in the morning it suddenly dawned on me that my remote server method had a generic EntityManager and I needed to cast it to my EM.
Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 29-Jun-2013 at 9:45am
Does the passing of the entity manager to my helper methods apply to all variables. Is it safe to have any static variables to store information or should i pass everything back and forth through methods?
 
 
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 29-Jun-2013 at 10:33am
You probably don't want any static variables unless you can lock access to them. The remote service method may be called concurrently on different threads from different clients. For example, you want to avoid a situation where UserA calls GetCurrentJobRefNo on one thread and sets shared variables, while milliseconds later UserB calls SetPacAnd401KBenefits on a different thread and that too tries to set shared variables.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down