AbdulAzizADQC
Novice

Connection of K2 in SharePoint throws Value cant be null Parameter Name Token Error

I am trying to open the connection of K2 server to open the worklist item of a process. but when openning a connection it throws the below error.

 

Error " Value cant be null Parameter Name Token.

 

 

Code snipt is below.

 

private Connection _connection;
private WorklistItem _WorkListItem;

 

protected void Page_Load(object sender, EventArgs e)
{
LoadActions();

}

 

protected LoadActions()

{

SourceCode.Workflow.Client.ConnectionSetup connectionSetup = new SourceCode.Workflow.Client.ConnectionSetup();
connectionSetup.ConnectionParameters["Authenticate"] = "true";
connectionSetup.ConnectionParameters["Integrated"] = "true";
connectionSetup.ConnectionParameters["IsPrimaryLogin"] = "true";
connectionSetup.ConnectionParameters["Port"] = "5252";
connectionSetup.ConnectionParameters["SecurityLabelName"] = "K2";
connectionSetup.ConnectionParameters["UserID"] = Context.User.Identity.Name;
connectionSetup.ConnectionParameters["WindowsDomain"] = "vvvvvvvvvv";
if (_connection == null)
{
_connection = new Connection();
_connection.Open(connectionSetup);
//_connection.ImpersonateUser(Context.User.Identity.Name);
//_connection.ImpersonateUser("adqcc\a.farooqi");
}

 

 

}

0 Kudos
Reply
11 Replies
Julia
Apprentice

Re: Connection of K2 in SharePoint throws Value cant be null Parameter Name Token Error

Hi, AbdulAzizADQC


 


Can you please double check your code sample if is correct.
 Please look into the following link to see if your code is correct.


 


Using SourceCode.Workflow.Client.Connection


 


Also make sure k2 is running


 


 


Kind Regards


 


Julia

0 Kudos
Reply
jikai
Apprentice

Re: Connection of K2 in SharePoint throws Value cant be null Parameter Name Token Error

Hi,

 

The SourceCode.Workflow.Client API will always run as the current security context, so there is no need for you to specify it again in the ConnectionSetup object. Another note is that you are missing the "Host" parameter. You need to specify the netbios name of the K2 server/cluster you want to connect to.

 

I think in your case, you can just replace the codes with

 

protected void LoadActions()

{

  if(_connection == null)

  {

    _connection = new Connection();

    _connection.Open("blackpearlServerName");

  }

 

  ......

}

 

Do remember to dispose/close the Connection object once you are done with it.

 

 

Cheers!

JK.

0 Kudos
Reply
AbdulAzizADQC
Novice

Re: Connection of K2 in SharePoint throws Value cant be null Parameter Name Token Error

I have check the link, still the same error.

 

below is my k2 host server logs.

 

Parameter name: token","","","K2-APP1-DEV:C:Program Files (x86)K2 blackpearlHost ServerBin","4430918","098543daa1704f6a96a5a43ff538a05c",""

"4430928","2014-06-25 15:05:22","Error","General","1","GeneralErrorMessage","K2Worker.AuthenticateIIdentity","1 Value cannot be null.

Parameter name: token","","","K2-APP1-DEV:C:Program Files (x86)K2 blackpearlHost ServerBin","4430928","2f2b627c9171481b9a1714f22ff2d64c",""

 

any idea.

0 Kudos
Reply
sbrownhuntoilco
Apprentice

Re: Connection of K2 in SharePoint throws Value cant be null Parameter Name Token Error

As @jikai pointed out, you are missing a Host parameter.

 

Also, consider using Integrated or Static Authentication in your connection string, then using the Connection.ImpersonateUser() method.

0 Kudos
Reply
AbdulAzizADQC
Novice

Re: Connection of K2 in SharePoint throws Value cant be null Parameter Name Token Error

thnx for the sugestion, if anyone can share the code. I have tried everything but no luck. the same error.

0 Kudos
Reply
Dimaz
Novice

Re: Connection of K2 in SharePoint throws Value cant be null Parameter Name Token Error

I have the same error message for this but this happen on K2 Worklist webpart so I cannot change or check the code within.

 

Any help would be appricated


k2worklist_1370.png
0 Kudos
Reply
johnz
Novice

Re: Connection of K2 in SharePoint throws Value cant be null Parameter Name Token Error

Hi all,

I have the same problem... 

 

Code:

Connection k2Conn = new Connection();
SCConnectionStringBuilder scBuilder = new SCConnectionStringBuilder();
scBuilder.Authenticate = true;
scBuilder.IsPrimaryLogin = true;
scBuilder.Integrated = true;
scBuilder.Host = "localhost";
scBuilder.Port = "5252";
k2Conn.Open("localhost", scBuilder); -> execption
...
k2Conn.Close();

 

- This code works in an old VM with MOSS 2007 and an older version of K2 Blackpearl.

- This code works in my current VM in an aspx page.

- This code dont work in my current VM running in a webpart in SharePoint.

 

Cant understand whats happening.... the log dont say nothing helpful.

 

Thanks

 

0 Kudos
Reply
johnz
Novice

Re: Connection of K2 in SharePoint throws Value cant be null Parameter Name Token Error

Hi all,

No one with an advise for this problem??? :(:(

0 Kudos
Reply
Alessandro
Novice

Re: Connection of K2 in SharePoint throws Value cant be null Parameter Name Token Error

Hi,


 


I recently contacted K2 for the same problem.


They replied me to follow the procedure below. That solved my problem, apparently my K2 server was not configured to work with SharePoint 2013 classic windows claims.


DO NOT FORGET TO BACKUP YOUR K2 DB first!


 


Regards,


Alex


 


 


 


How to configure classic windows claims to work with K2 from SharePoint Claims enabled site with K2 4.6.7


 



  • On your SP box, Open the SharePoint 2013 Management Shell and run the following to get the thumbprint of the SP signing certificate.









(Get-SPServiceApplication -Name SecurityTokenServiceApplication).SigningCertificateThumbprint


 



 


 



  • Open up SQL Server Management Studio

  • Make a backup of your K2 Database


Replace the highlighted thumbprint with the value from the script above and then execute this on your K2 server









DECLARE @issuerId INT


INSERT INTO [K2].[Identity].[ClaimIssuer] (Name,Description, Issuer, Thumbprint, Uri, UseForLogin)


VALUES ('SharePoint Windows STS', 'SharePoint Windows Authentication', 'SharePoint', '7AC848BCA2E9AA552F5051555BD388C45F30FABC',null, 0)


SET @issuerId = SCOPE_IDENTITY();


 


UPDATE [K2].[Identity].[ClaimTypeMapping]


SET IssuerID=@issuerId


WHERE ID=2


 


UPDATE [K2].[Identity].[ClaimTypeMap]


 SET ClaimType = 'http://schemas.microsoft.com/sharepoint/2009/08/claims/userlogonname'


WHERE ID=3


 


INSERT INTO [K2].[Identity].[ClaimTypeMap] (ClaimTypeMappingID, ClaimMappingType, OriginalIssuer, ClaimType, ClaimValue)


VALUES (2,'IdentityProviderClaim', 'SecurityTokenService', 'http://schemas.microsoft.com/sharepoint/2009/08/claims/identityprovider', 'windows')


 



 


The K2.Identity.ClaimsIssuer table should hold the new entry


 



  • Restart the server

Reply