Passing credentials through to exec command

Posted on 2005-05-03
Last Modified: 2013-12-13
How can I pass user credentials (using integrated Windows authentication with IIS) through to a command which is being executed via exec()?  I am trying to write a simple web-based script which will sync files from our development server to production using robocopy.  The problem is that when I execute robocopy through exec(), it runs under the IIS user who doesn't have permissions to the production share.

I want the robocopy command to be executed under the credentials of whoever is logged in.  I have tried using runas and CPAU but neither worked (runas doesn't allow passwords to be passed in, and CPAU opens the command in another window so no output back to the php script).  Also, I do not want to modify permissions, or create any new users to accomplish.  The users who are logging in having the necessary permissions.

I appreciate any help.
Question by:fentoozler
    LVL 1

    Author Comment

    LVL 5

    Expert Comment

    I don't think that's possible with how IIS does things.  You'll probably need to find another solution.  Does this absolutely have to work inside of PHP?
    LVL 1

    Author Comment

    I would like it to work in PHP, but any other language would be acceptible as long as it stays web-based.
    LVL 5

    Accepted Solution

    Web-based would be the problem.  The way that IIS is structured doesn't really allow for that kind of access.  Apache allows for a highler level of control over this sort of thing, but also falls a bit short.  The big reason behind this, of course, being security issues and concerns.  There might be some special way of doing it, but not that I'm aware of.  I would create a domain user for your IIS account and grant that user the necessary privileges to access the resources you need.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Easy Project Management (No User Manual Required)

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    A colleague recently asked me about how to give his client a small part of the web site that could be completely under the client's control.  Since I have done this sort of thing before to add emergency banners to a web site, I decided I would creat…
    Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit ( and similar technologies have enjoyed wide adoption, making it possib…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now