How does TimeZone.CurrentTimeZone work if run in an ASP.NET app? Does it return the timezone of the application pool running the application? If using impersonation, does it return the timezone of the user its impersonating?
It is the time zone on the computer where the code is executing. This is stored in HKLM i.e. it is a machine level setting not a user level. So it doesn't matter if impersonaltion is used. The value would still be the same. Check TimeZone.CurrentTimeZone which is TimeZoneInfo.Local
Related
I have a Web API application that needs to run a Python script which in turn runs a Perl script:) does some otehr stuff and get the output results from it.
The way I do this is with starting a Process:
var start = new ProcessStartInfo()
{
FileName = _pythonPath, //#"C:\Python27\python.exe",
Arguments = arguments, //#"D:\apps\scripts\Process.py
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
};
using (Process process = Process.Start(start))
{
using (StreamReader reader = process.StandardOutput)
{
var result = reader.ReadToEnd();
var err = process.StandardError.ReadToEnd();
process.WaitForExit();
return result;
}
}
The script inside tries to connect to Perforce server using P4 Python API and then Perl script call a P4 command as well. When running this code from Console application, everything goes fine. The program automatically gets the Perforce settings (I've got a P4V client with all the settings specified). But when running from ASP.NET Web API, it doesn't get the settigns and says that it cannot conenct to perforce:1666 server (I guess this is the standard value when no settign specified).
I do understand that not so many people use Perforce, especially in such way and can help here, but would like to know what is the difference between running this script from Console app and Web API app that mich cause this different behaviour.
One of the most obvious differences between running code from a console application and running code in IIS* is that, usually, the two pieces of code will be running under different user accounts.
Frequently, if you're experiencing issues where code works in one of those situations and not the other, it's a permissions or a per-user-settings issue. You can verify whether this is the case by either running the console application under the same user account that is configured for the appropriate IIS application pool, or vice verse, configure the application pool to use your own user account, and then see whether the problem persists.
If you've confirmed that it's a permissions issue and/or per-user-settings, then you need to decide how you want to fix it. I'd usually recommend not running IIS application pools under your own user account - if you cannot seem to get the correct settings configured for the existing application pool user, I'd usually recommend creating a separate user account (either locally on the machine or as part of your domain, depending on what's required) and giving it just the permissions/settings that it requires to do the job.
*IIS Express being the exception here because it doesn't do application pools and the code does end up running under your own user account.
I have a cube, which has been processed, works from the BID environment, and I can run my MDX query in both SSEM, and the BID env. I've created a role that contains the proper accounts/permissions, processed, and deployed the cube, re-processed it in SSEM, etc. Now I'm trying to connect, and extract the data using ASP.NET 4.0, but I'm getting this error:
The MyCube either does not exist or has not been processed
Here's my code:
String connectionString = "Provider=MSOLAP.3; Data Source=myhost;Initial Catalog=myCatalog; User ID=myaccount; Password=myamazinglysecurepassword;";
String mdxSQL = " my MDX, which was taken directly from BID env. cube in design mode";
AdomdConnection connection = new AdomdConnection(connectionString);
connection.Open();
AdomdCommand cmd = new AdomdCommand(mdxSQL, connection);
CellSet cst = cmd.ExecuteCellSet();
...etc
Note: we are not using MSMDPUMP.dll to connect, we'd like to avoid that.
Any Ideas?
A couple things to consider. How are users authenticating to your web app? What account is your application pool running as?
If you're using Integrated Windows in ASP.NET you may be getting a double-hop issue if IIS and SSAS on different servers. This would require you to set up Kerberos and trusted delegation SPN's between your application and the OLAP service.
See (SSAS and IIS):
http://msdn.microsoft.com/en-us/library/dn194199.aspx
http://technet.microsoft.com/en-us/library/dd632778.aspx
Otherwise there may be an issue with the account your application pool is running under. I see in your connection string you have a specific account - so I presume you are trying to connect as one account rather than delegating user credentials to OLAP. The process running w3wp.exe is the identity which will attempt to connect to SSAS. If your application pool is not runnning as a domain account is may not be able to authenticate to SSAS.
When I start the application pool, and request a page in an application in that pool, I get a "HTTP Error 503. The service is unavailable."
If I look at the application pools in IIS, I can see that it has now stopped. Going to the event viewer I find this error message:
'The identity of application pool Badge.Web is invalid. The user name or password that is specified for the identity may be incorrect, or the user may not have batch logon rights. If the identity is not corrected, the application pool will be disabled when the application pool receives its first request. If batch logon rights are causing the problem, the identity in the IIS configuration store must be changed after rights have been granted before Windows Process Activation Service (WAS) can retry the logon. If the identity remains invalid after the first request for the application pool is processed, the application pool will be disabled. The data field contains the error number.'
I'm very sure the credentials I'm using is correct. Something else is causing the app pool to stop.
I had similar problem today when an application pool using Windows user identity X stopped working after password change for that user.
Apparently, some information linked to old credentials was stored in the system, and I solved the problem by:
switching app pool identity to NetworkService
switching it back to X using the new password
So far it's working fine.
I found an article saying
The fix is to ensure that the Service/AppPool accounts have the ‘Log on as a batch job’ and ‘Log on as a service’ user rights on the server. This right can be found in Local Security Policy > Computer Configuration > Windows Settings > Local Policies > User Rights Assignment. Either remove the conflicting Group Policy and fix the Local Policy or add the rights to the Group Policy.
http://waveformation.com/2009/06/08/event-5021-the-identity-of-application-pool-lsgroupexpapppool-is-invalid/
While there may be several reasons why this may occur, in this specific case, the 503 error was occurring because the Application pool failed to start. This was because the password was changed recently for the Identity under which the application pool was trying to run. Fix was to go to the IIS Manager-> Application Pool -> Advanced Settings -> Process Model -> Identity and set the password to the new one.
It would also help to check the Event Viewer Logs(Event Viewer (Local) -> Windows Logs -> Application to look for specific causes of failure before proceeding to troubleshoot any further.
My problem was solved by changing Application Pool Identity to NetworkService, going to Advanced Settings > Process Model > Identity > NetworkService with the desired Application Pool selected.
I had the same issue and my solution was: Manager -> Application Pool -> "Select the pool" -> Advanced Settings -> Process Model -> Identity -> NetworkService
I need to run an executable from an ASP.NET app using Process. The .exe file is located inside the ASP.NET project - 'ProjectRoot/Utilities/utility.exe'
Why does this code fail to run it:
string path = Server.MapPath("/Utilities/");
string args = " etc etc";
Process p = Process.Start(new ProcessStartInfo(path + "utility.exe", args));
p.WaitForExit(3000);
I've tried "\\utility.exe" too.
The answer depends on the type of the occuring exception. By the way, if the identity of application pool (which is the equal position to the process in a windows app) is set to a limited user (as it is by default) you can not execute a process on the server because of security issues.
If you know about the consequences and the server is your own, you can change the identity of the application pool to an authorized user, then your application can do such a thing without any hesitation.
Cheers
There's a few things to check here.
The first thing is to ensure that string path = Server.MapPath("/Utilities/"); is a valid path and that utility.exe is in the correct location.
You said that it does not throw an exception, so the invocation of utility.exe should at least be valid. However, utility.exe may swallow any exceptions it in turn encounters (depends on how it was coded), which may be why it does not appear to be working.
On top of that, your args variable may be specifying a file or some other resource that utility.exe accesses. If it does swallow exceptions, it could be masking a permissions error if the application pool identity does not have access to the resouce.
I am currently working on an ASP.NET application in VB.NET and one of its functions is to use the Windows Task Scheduler. The application will need pretty much full control over this as it needs to Create, Modify, Delete and Run tasks.
I found this library to help with the whole thing and it works well but only locally on my Windows XP machine. As soon as I deploy the application to IIS6 on Windows Server 2003 and access pages that use my Scheduler object I get the following error.
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
I have looked for various solutions on the net that include giving specific users (and even Everyone) permissions to %windir%\Tasks using CACLS which didn't work and also using impersonation and adding the IUSER to the Backup Operations User Group which won't work as the Application MUST use Windows Integrated Authentication.
One thing that is confusing me about the whole situation is that the User I am logged in as when testing the application can quite happily remote desktop and login to the server and muck about with the Task Scheduler. Also, if I run the application locally in Visual Studio (still under the same User) and point the application at the Task Scheduler of the server it works fine. Further to this, If I run the application from the server and point it at my local Task Scheduler I get the same "Access Denied" error. All of that makes me think it is not a Task Scheduler permissions thingy but something to do with permissions on some components that the Task Scheduler Library is trying to use.
Does any one know what I could do to resolve this or even just a pointer in the right direction as this has been driving me crazy for over a day now. I must say I am a bit of a newbie when it comes to IIS Issues, Impersonation and Windows Server Security.
Thank you very much
Hey there i kno i may be late what you can do is either set the task to run under the NT AUTHORITY\SYSTEM for that use this
(C#)
string NULL = null ;
task.SetAccountInformation("", NULL);
and to set it for the current user give the username
string username = "your xp username";
or
string username = System.Security.Principal.WindowsIdentity.GetCurrent().Name ;
string NULL = null ;
task.SetAccountInformation(username, NULL);
that will work for you i hope !!!! and let me know how it was !!!