Hi Anurag,
System Preparation, Basic Configuration steps needs to be configured properly. All these users gets created (roles updated/adjusted) during these steps itself. Even if this system is your CUA Administrator Client you need these users to be created with proper authorization.
I will advise first to configure your Solution Manager system properly for System Preparation & Basic Configuration steps. Then configure your ECC system with Managed system steps and then perform this Custom Code configuration.
Also it seems you are using your own userid to configure these steps. Do your userid have all proper authorization (equivalent to SOLMAN_ADMIN)?
Thanks,
MPS