• Register
0 votes
132 views

Problem :

I am very new to ASP.Net. I have created my first ASP.Net application which impersonates the user in order to create the AD group, and after that it launches the powershell process as the user saperately.

But because of some reason the group creation works fine and shows as success in the Event Viewer, and when it tries to run my PowerShell script, I face the following error:

The user has not been granted the requested logon type at this machine.

The below is my code which is failing:

SecureString securePassword = new SecureString();
foreach (char c in model.AdminPassword)
{
securePassword.AppendChar(c);
}
PSCredential psCredential = new PSCredential("CONTOSO\\" + User.Identity.Name, securePassword);
ProcessStartMyinfo myinfo = new ProcessStartMyinfo("c:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe", "c:\\PowershellScripts\\EnableDL.ps1 -dlName '" + model.Name + "'");
myinfo.UseShellExecute = false;
myinfo.RedirectStandardOutput = true;
myinfo.RedirectStandardError = true;
myinfo.RedirectStandardInput = true;
myinfo.CreateNoWindow = true;
myinfo.Domain = "CONTOSO.COM";
myinfo.UserName = User.Identity.Name;
myinfo.Password = securePassword;

Is there any way to remove this error? I would rather not compromise with the security policy with the server ideally, and this application will be used by around 100+ users.

6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I have managed to find the solution for you. You just need to go to Start->Administrative Tools->Local Security Policy.

And navigate to Local Policies->User Rights Assignment->Allow Log On Locally, and finally add the required usernames of the accounts/groups needs access.

9 7 4
38,600 points

Related questions

0 votes
1 answer 8 views
8 views
Problem: For some reason the group creation works fine and shows as success in the Event Viewer, but when it tries to run the PowerShell script, I get the following error: The user has not been granted the requested logon type at this machine.
asked Mar 20 ummesalma 29.2k points
0 votes
1 answer 309 views
309 views
Problem : I have my home network with the XP laptop, a Vista desktop and now new one Win 7 desktop. I have attached my Win7 to my existing home network. I can see and access files on my XP & Vista machines from my Win 7 box. I can see the Win 7 ... message. Logon failure: the user has not been granted the requested logon type for this computer. Please let me know if any solution on my problem.
asked Dec 7, 2019 alecxe 7.5k points
1 vote
1 answer 4 views
4 views
Problem: Need help of expert to solve this error. The permissions granted to user are insufficient for performing this operation. (rsaccessdenied).
asked Apr 22 PkGuy 23.5k points
0 votes
1 answer 8 views
8 views
Problem: I'll make a submission for a response to my question. Please, I have searched the internet but have not found any useful material, and I am now having trouble continuing my studies.
asked Apr 1 rakib1 51.5k points
1 vote
1 answer 3 views
3 views
Problem: After I tried to connect the data base using SQL developer I got this error: An error was encountered performing the requested operation.
asked Apr 25 PkGuy 23.5k points
0 votes
1 answer 1 view
1 view
Problem: Why I am getting an error > Powershell cannot be loaded because running scripts is disabled on this system.
asked Apr 28 ummeshani 8.8k points
1 vote
1 answer 677 views
677 views
Problem : We are now running the 32-bit Windows server 2008 with the IIS version of 7. We are trying to publish the asp.net 4.0 webapp but so far our attempts have failed and only yielded the few warnings in our serverlog without even the stopping our 4.0 application ... very badly after that we ran out of the ideas on what to do on our issue so any form of the input would be greatly appreciated.
asked Dec 30, 2019 alecxe 7.5k points
1 vote
1 answer 14 views
14 views
Problem: How to prevent hack attempts. Special privileges assigned to new logon hack.
asked Mar 26 PkGuy 23.5k points
0 votes
1 answer 3 views
3 views
Problem: Trying to create COM-object on the server. getting the error: Creating an instance of the COM component with CLSID {530A1815-820C-11D3-BBB7-008048DE406A} from the IClassFactory failed due to the following error: 80070776.
asked Apr 19 ummesalma 29.2k points
0 votes
1 answer 2 views
2 views
Problem: How to fix this error > Unable to find the requested .net framework data provider. it may not be installed
asked Apr 25 ummeshani 8.8k points