How does 'net use' command work with different users and different processes












0















Recently, I wrote a python script to do some routine file manipulation and maintenance for a folder on a shared network drive (one that requires authentication to access).



When I ran the the script on my local machine, it worked and was able to access the network drive no problem. Then I put the script on a remote machine and had Jenkins run it. Jenkins was giving me an access denied error because Jenkins was installed as a service run by the local system account which did not have access to the shared drive.



So, after looking for solutions I saw that I could use the net use command to gain network access with other credentials. I tried writing a powershell script that used net use, with my login info passed, to call the python script.



This did not work.



Finally, I tried using the net use command within the python script using os.sys('net use user/pass') and it worked!



So, my question is.. why did it work when the net use command was placed within the python script but not within the powershell script used to invoke the python one?



Most of what I read about 'net use' online describes it for 'mapping' to a network drive? But my computer already knew the drive existed and where it was it just did not have access to it until I passed in a username and password with the command. What is the scope of the network authentication from this command? Do child processes not keep that same authentication?










share|improve this question























  • Could the Jenkins service be configured to use a user account which would then have access to the share drive? My first thought for the problem as described was the EnableLinkedConnections registry key. For example, by default, if you map a drive in a command prompt, you can't see it in an elevated command prompt unless the EnableLinkedConnections registry key is set. I wonder if this could be part of what you're seeing without knowing all the details.

    – HelpingHand
    Jan 15 at 20:40











  • Thanks for the tip about the registry key. I shall look into that. Just to be clear, I have it working now by calling the net use command within the python script. I am just trying to understand why the other way didn't work. As for the other suggestion, I maybe could have had the Jenkins service run as my own user account instead of the system, but that seemed like a bad idea to me because other people running Jenkins could do things under my accounts credentials.

    – forrestaustin
    Jan 15 at 21:15











  • Could you create a dedicated service account to use rather than your account?

    – HelpingHand
    Jan 15 at 21:20
















0















Recently, I wrote a python script to do some routine file manipulation and maintenance for a folder on a shared network drive (one that requires authentication to access).



When I ran the the script on my local machine, it worked and was able to access the network drive no problem. Then I put the script on a remote machine and had Jenkins run it. Jenkins was giving me an access denied error because Jenkins was installed as a service run by the local system account which did not have access to the shared drive.



So, after looking for solutions I saw that I could use the net use command to gain network access with other credentials. I tried writing a powershell script that used net use, with my login info passed, to call the python script.



This did not work.



Finally, I tried using the net use command within the python script using os.sys('net use user/pass') and it worked!



So, my question is.. why did it work when the net use command was placed within the python script but not within the powershell script used to invoke the python one?



Most of what I read about 'net use' online describes it for 'mapping' to a network drive? But my computer already knew the drive existed and where it was it just did not have access to it until I passed in a username and password with the command. What is the scope of the network authentication from this command? Do child processes not keep that same authentication?










share|improve this question























  • Could the Jenkins service be configured to use a user account which would then have access to the share drive? My first thought for the problem as described was the EnableLinkedConnections registry key. For example, by default, if you map a drive in a command prompt, you can't see it in an elevated command prompt unless the EnableLinkedConnections registry key is set. I wonder if this could be part of what you're seeing without knowing all the details.

    – HelpingHand
    Jan 15 at 20:40











  • Thanks for the tip about the registry key. I shall look into that. Just to be clear, I have it working now by calling the net use command within the python script. I am just trying to understand why the other way didn't work. As for the other suggestion, I maybe could have had the Jenkins service run as my own user account instead of the system, but that seemed like a bad idea to me because other people running Jenkins could do things under my accounts credentials.

    – forrestaustin
    Jan 15 at 21:15











  • Could you create a dedicated service account to use rather than your account?

    – HelpingHand
    Jan 15 at 21:20














0












0








0


1






Recently, I wrote a python script to do some routine file manipulation and maintenance for a folder on a shared network drive (one that requires authentication to access).



When I ran the the script on my local machine, it worked and was able to access the network drive no problem. Then I put the script on a remote machine and had Jenkins run it. Jenkins was giving me an access denied error because Jenkins was installed as a service run by the local system account which did not have access to the shared drive.



So, after looking for solutions I saw that I could use the net use command to gain network access with other credentials. I tried writing a powershell script that used net use, with my login info passed, to call the python script.



This did not work.



Finally, I tried using the net use command within the python script using os.sys('net use user/pass') and it worked!



So, my question is.. why did it work when the net use command was placed within the python script but not within the powershell script used to invoke the python one?



Most of what I read about 'net use' online describes it for 'mapping' to a network drive? But my computer already knew the drive existed and where it was it just did not have access to it until I passed in a username and password with the command. What is the scope of the network authentication from this command? Do child processes not keep that same authentication?










share|improve this question














Recently, I wrote a python script to do some routine file manipulation and maintenance for a folder on a shared network drive (one that requires authentication to access).



When I ran the the script on my local machine, it worked and was able to access the network drive no problem. Then I put the script on a remote machine and had Jenkins run it. Jenkins was giving me an access denied error because Jenkins was installed as a service run by the local system account which did not have access to the shared drive.



So, after looking for solutions I saw that I could use the net use command to gain network access with other credentials. I tried writing a powershell script that used net use, with my login info passed, to call the python script.



This did not work.



Finally, I tried using the net use command within the python script using os.sys('net use user/pass') and it worked!



So, my question is.. why did it work when the net use command was placed within the python script but not within the powershell script used to invoke the python one?



Most of what I read about 'net use' online describes it for 'mapping' to a network drive? But my computer already knew the drive existed and where it was it just did not have access to it until I passed in a username and password with the command. What is the scope of the network authentication from this command? Do child processes not keep that same authentication?







windows networking powershell operating-systems jenkins






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 15 at 18:44









forrestaustinforrestaustin

1




1













  • Could the Jenkins service be configured to use a user account which would then have access to the share drive? My first thought for the problem as described was the EnableLinkedConnections registry key. For example, by default, if you map a drive in a command prompt, you can't see it in an elevated command prompt unless the EnableLinkedConnections registry key is set. I wonder if this could be part of what you're seeing without knowing all the details.

    – HelpingHand
    Jan 15 at 20:40











  • Thanks for the tip about the registry key. I shall look into that. Just to be clear, I have it working now by calling the net use command within the python script. I am just trying to understand why the other way didn't work. As for the other suggestion, I maybe could have had the Jenkins service run as my own user account instead of the system, but that seemed like a bad idea to me because other people running Jenkins could do things under my accounts credentials.

    – forrestaustin
    Jan 15 at 21:15











  • Could you create a dedicated service account to use rather than your account?

    – HelpingHand
    Jan 15 at 21:20



















  • Could the Jenkins service be configured to use a user account which would then have access to the share drive? My first thought for the problem as described was the EnableLinkedConnections registry key. For example, by default, if you map a drive in a command prompt, you can't see it in an elevated command prompt unless the EnableLinkedConnections registry key is set. I wonder if this could be part of what you're seeing without knowing all the details.

    – HelpingHand
    Jan 15 at 20:40











  • Thanks for the tip about the registry key. I shall look into that. Just to be clear, I have it working now by calling the net use command within the python script. I am just trying to understand why the other way didn't work. As for the other suggestion, I maybe could have had the Jenkins service run as my own user account instead of the system, but that seemed like a bad idea to me because other people running Jenkins could do things under my accounts credentials.

    – forrestaustin
    Jan 15 at 21:15











  • Could you create a dedicated service account to use rather than your account?

    – HelpingHand
    Jan 15 at 21:20

















Could the Jenkins service be configured to use a user account which would then have access to the share drive? My first thought for the problem as described was the EnableLinkedConnections registry key. For example, by default, if you map a drive in a command prompt, you can't see it in an elevated command prompt unless the EnableLinkedConnections registry key is set. I wonder if this could be part of what you're seeing without knowing all the details.

– HelpingHand
Jan 15 at 20:40





Could the Jenkins service be configured to use a user account which would then have access to the share drive? My first thought for the problem as described was the EnableLinkedConnections registry key. For example, by default, if you map a drive in a command prompt, you can't see it in an elevated command prompt unless the EnableLinkedConnections registry key is set. I wonder if this could be part of what you're seeing without knowing all the details.

– HelpingHand
Jan 15 at 20:40













Thanks for the tip about the registry key. I shall look into that. Just to be clear, I have it working now by calling the net use command within the python script. I am just trying to understand why the other way didn't work. As for the other suggestion, I maybe could have had the Jenkins service run as my own user account instead of the system, but that seemed like a bad idea to me because other people running Jenkins could do things under my accounts credentials.

– forrestaustin
Jan 15 at 21:15





Thanks for the tip about the registry key. I shall look into that. Just to be clear, I have it working now by calling the net use command within the python script. I am just trying to understand why the other way didn't work. As for the other suggestion, I maybe could have had the Jenkins service run as my own user account instead of the system, but that seemed like a bad idea to me because other people running Jenkins could do things under my accounts credentials.

– forrestaustin
Jan 15 at 21:15













Could you create a dedicated service account to use rather than your account?

– HelpingHand
Jan 15 at 21:20





Could you create a dedicated service account to use rather than your account?

– HelpingHand
Jan 15 at 21:20










0






active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1394645%2fhow-does-net-use-command-work-with-different-users-and-different-processes%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1394645%2fhow-does-net-use-command-work-with-different-users-and-different-processes%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

If I really need a card on my start hand, how many mulligans make sense? [duplicate]

Alcedinidae

Can an atomic nucleus contain both particles and antiparticles? [duplicate]