Cookie Monster
Cookie Monster

Reputation: 1791

Prompt for credentials in ASP.NET / C# page, pass to PowerShell

I'm looking to build a proof of concept / demo webpage that will:

I have an ASP.NET Web Application project with Visual C# (similar to the one here). I have the page up and running (i.e. it runs with the appropriate account, it runs PowerShell, etc.) - I want to prompt for and store credentials in a reasonably secure manner. I assume there is some standard way to do this. Or am I reading too much into this as this is a server side application?

Here are excerpts from my code thus far:

Upvotes: 1

Views: 4867

Answers (1)

HAL9256
HAL9256

Reputation: 13483

I think the easiest way is to use impersonation. i.e. you get the credentials of the user, and launch the powershell process as that user which allows you to execute anything you want as that user.

See:

Execute PowerShell cmdlets from ASP.NET With User Impersonation - Has steps to impersonate the current user to run PowerShell

or

How to run PowerShell scripts from ASP.NET with Impersonation - StackOverflow question on how to run PowerShell with impersonation.

Upvotes: 2

Related Questions