Monday, July 17, 2017

Convert pfx certificate to base64 string using Powershell



Convert pfx certificate to base64 string using Powershell


Use the below script to convert to pfx certificate to convert to Base64 string using Powershell

$fileContentBytes = get-content 'C:\Temp\DOClientTestCert.pfx' -Encoding Byte

[System.Convert]::ToBase64String($fileContentBytes) | Out-File 'C:\Temp\DOClientTestCert_base64.txt'




Reference :
https://sivapalla.wordpress.com/2016/03/05/convert-pfx-certificate-to-base64-string-using-powershell/

Note: This post directly copy from above link , just to keep a kind of handy document with me , no any intention to copy. If require i can delete it. 

Regards
Kundan

Friday, March 24, 2017

Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'

Problem :


Error : Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'




Solution :


Work Around:


Adding Microsoft.CSharp.dll as a reference fixes the issue








Reference :


https://connect.microsoft.com/VisualStudio/feedback/details/1630573/missing-compiler-required-member-microsoft-csharp-runtimebinder-csharpargumentinfo-create

Wednesday, March 8, 2017

Track Logic App's WorkFlow "Client Tracking ID" inside same Logic App

Problem :  Inside logic App how to track "Client Tracking ID" (it can be consider as co-relation ID which doesn't change when run goes through multiple logic Apps) of the same logicApp

Solution:

Write following line wherever you need to track the Run Identifier

@trigger()['clientTrackingId']
















Thursday, January 12, 2017

Remove BOM from string

Problem: Sometimes due to BOM (Binary object Mark) string couldn't be loaded into XMLDocument etc.


Solution:


Replace string


string str_xml = <xml in string format>
str_xml = str_xml.Replace("\ufeff", "");









Friday, April 22, 2016

User belongs to which windows groups

Problem :



To find the user belongs to which windows groups




Solution:



net user <userName> /domain







Wednesday, September 23, 2015

Visual Studio menu items showing twice/duplicate


Problem Statement:



  • While opening the visual all the menu iteams are show double-double / duplicate.




Solution:



  • Open Visual studio command prompt
  • Run following commands:
Devenv.exe /ResetSettings
Devenv.exe /resetuserdata


Reference :

http://stackoverflow.com/questions/16060832/duplicate-menu-items-vs-2012



Regards
Kundan


Tuesday, July 7, 2015

502.3 - Bad Gateway security error code

Problem Statement:


Whenever you are using IIS ARR with URL Rewrite for Reverse proxy. 
HTTPS to HTTPS. You might receive following error.

Error: IIS 7.5 Detailed Error - 502.3 - Bad Gateway security error code 0x80072f8f



Casue of Problem:


IIS where you configured ARR it doesn't trust the BackEnd IIS Server certificate.


Solution:


Please export the Back End IIS Server certificate and Import it into IIS-ARR local machine under
Trusted Store.

Reference: http://blog.lint.at/iis-as-reverseproxy-with-ssl-offloading/





Friday, July 3, 2015

System.Configuration The entry 'XXX has already been added (C:\Program Files (x86)\Microsoft BizTalk Server 2010\BTSNTSvc64.exe.Config)

Problem Statement:
Sometimes if we get following kind of error message:

Error writing to log. System.Configuration The entry 'XXXX' has already been added. (C:\Program Files (x86)\Microsoft BizTalk Server 2010\BTSNTSvc64.exe.Config line 156)


Cause of Error:

This is the result of a double entry in the config files BTSNTSvc.exe.Config or BTSNTSvc64.exe.Config and machine.config

Solution:

Option 1:

Search machine.config and BTSNTSvc.exe.Config ( or BTSNTSvc64.exe.Config) and remove double entry.


Option 2:

In BTSNTSvc.exe.Config ( or BTSNTSvc64.exe.Config) replace below lines of code.

      <add name="XXXX" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

        filePath="D:\AAAA\Config\BBBB.config" />

with


<remove name="XXXX"/>
 <add name="XXXX" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

        filePath="D:\AAAA\Config\BBBB.config" />


Then it will work :-)

Regards
Kundan

Tuesday, May 26, 2015

Clean Up BizTalk Databases and Logs

Clean Up BizTalk Databases and Logs


Problem Statement: Usually on Development machine biztalk databases logs grows and fill most of the space of disk. 

Cause: This usually happens when the biztalk jobs either not configured or SQL Agent is not running.

Solution:
Note: This should not be applied on PRODUCTION Servers.

Execure below lines of code on SQL Sever where biztalk is configured.

Step 1:


=====Script Start==============
USE master
ALTER
 DATABASE BizTalkMgmtDb SET RECOVERY SIMPLE WITH NO_WAITALTER DATABASE BizTalkDTADb SET RECOVERY SIMPLE WITH NO_WAITALTER DATABASE BizTalkMsgBoxDb SET RECOVERY SIMPLE WITH NO_WAITGO

Use BizTalkMgmtDbDBCC SHRINKFILE (N'BizTalkMgmtDb_log' , 0, TRUNCATEONLY)GO
Use BizTalkDTADbDBCC SHRINKFILE (N'BizTalkDTADb_log' , 0, TRUNCATEONLY)GO
Use BizTalkMsgBoxDbDBCC SHRINKFILE (N'BizTalkMsgBoxDb_log' , 0, TRUNCATEONLY)GO

USE master
ALTER
 DATABASE BizTalkMgmtDb SET RECOVERY FULL WITH NO_WAIT
ALTER DATABASE BizTalkDTADb SET RECOVERY FULL WITH NO_WAITALTER DATABASE BizTalkMsgBoxDb SET RECOVERY FULL WITH NO_WAITGO
=======Script End=================

Step 2: 

a. Go to BizTalk installation directory example :
C:\Program Files (x86)\Microsoft BizTalk Server 2010\Schema\
b. run script msgbox_cleanup_logic.sql  on BizTalk MsgBox DB database.
c. Now execute bts_CleanupMsgbox from BizTalk MsgBox DB database.



References:

http://blogical.se/blogs/johan/archive/2011/12/22/truncate-biztalk-servers-database-log-files-to-clear-up-space.aspx

https://masteringbiztalkserver.wordpress.com/2011/01/10/reset-biztalk-server-msgbox-database-%E2%80%93-useful-for-all-developers/

Regards
Kundan


Friday, November 14, 2014

BizTalk WCF-BasicHttp Transport with Message Credentials


BizTalk WCF-BasicHttp Transport with Message Credentials
(WS-I Basic Profile Web Services Interoperability)

Introduction

Requirement is to expose secure BizTalk web-service (https) [SSL] over internet/intranet with client authentication not at the Transport layer but at the Message Layer by UserID/Password in SOAP header.
Along with that web-service can be consumed by any technology client i.e “Web Services Interoperability” and follows WS-Security (WS-I Basic Profile) guidelines.
Such scenario can be implemented in biztalk by following the below steps.

Background

Sometime users of web-service need to trust on web-service they are using for sending and receiving messages.
At the same time web-service also authenticate the users of service.
Service authentication by users/client:  Every Secure web-service (https) is associated with “Server Certificate” issued by well known “Certificate Authority”. Which is been verified by clients of that service while using/browsing.
Service authenticates users/clients:  Service also should authenticate, that the service is being used by the users which comes under its Trusted Zone. 
Client should send the UserID/Password in SOAP header.

Solution

 Following are steps need to follow to achieve this in BizTalk Server.
1.       Create/Get Server Certificate :
If it is for testing then Create Self Sign Server Certificate. If it is for production then need to get the Server certificate from CA

Following are the steps to create Self sign server certificate.

a.       Go to IIS and select “Server” and in features view select “Server Certificates”.






b.       Select Create Self Signed Certificate . Then give some friendly name


Click Ok, then
Click to View and see the certificate details.

2.       Create Secure Site in IIS (https) :

a.       Right Click Sites and select new Site
b.      Provide the site details as shown below.
Protocol : https
SSL certificate : <which created the previous step>

















3.       Enable SSL on IIS “MySecureSite”.






4.       Create BizTalk Solution.

a.       Solution can be with Orchestration or without Orchestration. In this example will create a solution with BizTalk orchestration and expose it as WCF service.













b.      Service with “http” is deployed on IIS but in “Default Web Site”. No we have to move it to “MySecureSite” which is https.

Add new Application to “MySecureSite” with the same name i.e. “BTS_Test_ProjMsgAuth” and provide the same physical path.




i.                     Now remove the application from “Default Web Site” [Note: but don’t delete from physical path]

ii.                   Check the SSL settings should be like below shown



iii.                  Go to Physical path of “BTS_SecureWebService1” and open web.config

iv.                  

                     Comment line start with

“<endpoint name="HttpMexEndpoint"……………”

And Un-Comment line just below that start with

“<endpoint name="HttpsMexEndpoint"





v.                   For following lines

        <behavior name="ServiceBehaviorConfiguration">
          <serviceDebug httpHelpPageEnabled="true" httpsHelpPageEnabled="false" includeExceptionDetailInFaults="false" />
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
        </behavior>

Change http to false and https to true, like done below.


       <behavior name="ServiceBehaviorConfiguration">
          <serviceDebug httpHelpPageEnabled="false" httpsHelpPageEnabled="true" includeExceptionDetailInFaults="false" />
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
        </behavior>


vi.                 Add following lines under  <system.web>


For allowing Users:

<system.web>
…………..
…………  

   <authorization>
      <allow roles="" users="<Domain>\<usernme>" />
      <deny users="*" />
    </authorization>
</system.web>

For allowing Group:

<system.web>
…………..
…………  
   <authorization>
      <allow roles="<Domain>\<groupname>" users="" />
      <deny users="*" />
    </authorization>
</system.web>











c.       Go to BizTalk Server Admin console and navigate to your deployed  Application.

Go to BizTalk Received Location and confirm the bindings






Go to Security tab and change the settings as shown below.














d.      Configure the BizTalk deployed application binding and then start it.







5.       Browse Service: Try to browse the service.

If you get error : HTTP Error 503. The service is unavailable
They AppPool under which service is configured to run either not started or having wrong credentials.

[Note: App Pool under which biztalk server need to run should be same user configured for “Isolated Host Instance” in BizTalk.]

After browsing service looks like this……….








6.       Who are authorized to use this service?
·         Client message should always be associated with userID/Password in SOAP Header
SOAP Message format is shown below.

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
              xmlns:xsd="http://www.w3.org/2001/XMLSchema"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xmlns:xop="http://www.w3.org/2004/08/xop/include"
              xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
  <env:Header>
    <!--SOAP header with userid and password-->
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" env:mustUnderstand="1">
      <wsse:UsernameToken wsu:Id="UsernameToken-22D614527BEC949AB414127559566081">
        <wsse:Username>KundanKarma</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">KKAADDAADASDASD</wsse:Password>
      </wsse:UsernameToken>
    </wsse:Security>
  </env:Header>
  <env:Body>
    <!--Body of the message-->
  </env:Body>
</env:Envelope>





7.       Test : 

Client of the service is independent of Technology. Any web technology client can call the webservice. But client should send the

                     userID/Password in SOAP Header
                    SOAP Message format is shown below.

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
              xmlns:xsd="http://www.w3.org/2001/XMLSchema"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xmlns:xop="http://www.w3.org/2004/08/xop/include"
              xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
  <env:Header>
    <!--SOAP header with userid and password-->
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" env:mustUnderstand="1">
      <wsse:UsernameToken wsu:Id="UsernameToken-22D614527BEC949AB414127559566081">
        <wsse:Username>KundanKarma</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">KKAADDAADASDASD</wsse:Password>
      </wsse:UsernameToken>
    </wsse:Security>
  </env:Header>
  <env:Body>
    <!--Body of the message-->
  </env:Body>
</env:Envelope>














In this example I am going to show the test by SOAPUI


SOP UI Prepration:
a.       Open SOAP UI

b.      Take WSDL of Service and create SOAP UI project

c.       Test the service with input message like below:


<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
              xmlns:xsd="http://www.w3.org/2001/XMLSchema"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xmlns:xop="http://www.w3.org/2004/08/xop/include"
              xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
  <env:Header>
    <!--SOAP header with userid and password-->
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" env:mustUnderstand="1">
      <wsse:UsernameToken wsu:Id="UsernameToken-22D614527BEC949AB414127559566081">
        <wsse:Username>KundanKarma</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">KKAADDAADASDASD</wsse:Password>
      </wsse:UsernameToken>
    </wsse:Security>
  </env:Header>
  <env:Body>
    <!--Body of the message-->
  </env:Body>
</env:Envelope>