When i used the WNetAddConnection2 method, it returned 1219 as result code. Well, it worked for my own credentials, but when i passed the service credentials to access the files. I was facing this problem.

After querying uncle Google, I realized that the natively windows allows only one user to be used to map the network drive, i.e, i cannot use my own credentials and service credentials (both being different) to access the same network share from the same server concurrently.

As as alternative, i use the ip Address to access the networkshare using my service account. and Violla, it worked like a charm.