SeAuditPrivilege error - wcf

My WCF service has this config setting for Security Audit:
<serviceSecurityAudit auditLogLocation="Default"
suppressAuditFailure="false"
ServiceAuthorizationAuditLevel="SuccessOrFailure"
messageAuthenticationAuditLevel="SuccessOrFailure"/>
When a method is invoked for this service locally using ASP.Net Dev Server, it results into this error:
<ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<HelpLink i:nil="true"/>
<InnerException i:nil="true"/>
<Message>The process does not possess the 'SeAuditPrivilege' privilege which is required for this operation.</Message>
<StackTrace>at System.IdentityModel.Privilege.EnableTokenPrivilege(SafeCloseHandle threadToken)
...
I am having Windows7 on my local machine.
Can anyone please guide what could be the issue?
Thank you!

To get rid of 'SeAuditPrivilege' error, I had to change
auditLogLocation="Default"
to
auditLogLocation="Application"
I am having Windows7 and for some reason, it was not able to write to "Security Logs" which is default for Windows 7 as this link from MS suggests - http://msdn.microsoft.com/en-us/library/system.servicemodel.auditloglocation%28v=vs.110%29.aspx
Default
Specifies the default location, which is determined by the operating system.
If writing to the Security log is supported (such as on Windows Vista and Windows
Server 2003 and later platforms), the default log location is the Security log.
Otherwise (such as in Windows XP SP2), the default log location is the Application log.
I had to change the value from "Default" to "Application" to make it work.
HTH.

Related

problem when publishing asp.net core project on a server

I'm implementing asp.net core project. I published my project into a package and set it on a main server, but, the database was set on another server. To do that, in the part of connection string of appsetting file, I just changed the server name and database name and when running the project I confront with the following error:
I appreciate if anyone can suggest me a solution for it.
This error indicates that an exception has occurred in your project, but since it is not a development environment, it is impossible to show you the real error message.
If you want to get the real error information, you can try to change the value of the ASPNETCORE_ENVIRONMENT variable from Production or other to Development in web.config file, and then refresh to see the real error information.
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
For more details, please refer to this discussion.

ASP.NET Core hosting - 500 internal server error

I am trying to publish as ASP.NET Core project with a hosting provider that supports ASP.NET Core. I am getting 500 Internal Server Error which I believe is very common. So I searched through the internet and various forums and then I checked the processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" in web.config and they look to be correctly converted with processPath="dotnet" and arguments=".\MyApplication.dll".
I also checked the connection string and it points to production DB server that's working. I confirmed the DB connection by changing the connection string to production DB and running project local. It works and I get the production DB access.
I also tried to get the error info by using the below in my Startup.cs (irrespective of env):
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
app.UseBrowserLink();
I have also enabled stdoutLog in web.config, but I don't see that folder either:
stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout"
I also tried to change applicationUrl and launchUrl in launchSettings.json to my prod Url, but that didn't work as well.
So, the 500 Internal Server Error refuses to go away, and I still don't have a useful error message. The page just says:
Oops.
500 Internal Server Error
An error occurred while starting the application.
I would really appreciate if someone could help me here.
I have also enabled stdoutLog in web.config as but I don't see that folder either:
stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout"
There is one trick here - you must create both folders logs and stdout manually - then and only then IIS will create log file inside logs folder (not stdout as you could expect) - don't ask me why, because I don't know why ;)
Oops. 500 Internal Server Error An error occurred while starting the application.
Usually, means problems with a configuration in Startup.cs - the most common problems include an issue with DB itself, an issue with migrations (if you are using Code First approach), problems with appsettings.js, problems with Social Logins credentials (like missing SecretKey)...
Please refer to log file in .\logs\stdout - this is the quickest way to find details about the problem :)
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
Those will work after your WebApp fully started, but not while starting the application.
in web.config file change modules="AspNetCoreModuleV2" to modules="AspNetCoreModule"
and watch this video
https://www.youtube.com/watch?v=clCR3k6kkD8
Thanks to Lukasz for his comments. I was able to see the log and it stated that "ClientId option must be provided". The problem was with the UserSecrets. Since secrets.json is only available in Development, there were no secrets found in Production. Once I had the secrets in my appSettings.json, it worked fine.
Moreover, To replicate this in Local environment, just go to Project properties and change the environment variable ASPNETCORE_ENVIRONMENT to 'Production' and run in local. This will replicate the 500 Internal Server Error in local and you'll get the error message.
Also, ensure that the ASP.NET Core Windows Server Hosting bundle is installed. THis creates a reverse proxy between IIS and the Kestral server.
More Info:
https://learn.microsoft.com/en-us/aspnet/core/publishing/iis?tabs=aspnetcore2x#tabpanel_tfsY37MhAQ_aspnetcore2x
I would like to add some more info to #Lukasz Makowej answer.
I found out the reason why to have to create the folder, in microsoft documentation it is said that:
stdoutLogFile - Optional string attribute.
".....Any folders provided in the path must exist in order for the module to create the log file...."
So you have to create it yourself :)
Check it out here:
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-2.0
I also must said that in my case I had to validate that the web-site had the permissions to access to the "log" folder.
Make sure your web.config is good. I've been stomped more than once by a syntactically good web.config that referred to a module (Rewrite) that wasn't on the server. No error messages anywhere, other than the 500 response error.
Std log wasn't working for me, I had to uninstall all .ENT Core runtime / SDK versions from the server and my local to install the latest one and it worked after publishing everything again from scratch.
Another thing that helped was binding the IIS app to port 5000 without any dns so it actually showed me errors on http://localhost:5000
Encountered this issue yesterday, we also had no logging, no eventlog message whatsoever.
Then we checked the site's authentication settings via the IIS-manager to double-check the settings. And pop suddenly a popup with an error message 'Error on line XXXX'.
Turned out the configuration section was locked in the website's config at server-level.
So try unlocking the relevant IIS configuration settings at server level, as follows:
Open IIS Manager
Select the server in the Connections pane
Open Configuration Editor in the main pane
In the Sections drop down, select the section to unlock, e.g. system.webServer => security => authentication
Click Unlock Attribute in the right pane
Repeat for any other settings which you need to unlock
Restart IIS (optional) - Select the server in the Connections pane, click Restart in the Actions pane

Can I ignore CWWKS3005E messages on worklight server logs?

I have an application running on Worklight 6.1 and I am seeing this messages on the log.
CWWKS3005E: A configuration exception has occurred. No UserRegistry implementation service is available
I don't need to authenticate the users on my application, can I ignore this message?
I'm not sure, but you can try to cancel logging for this specific package using following log configuration in server.xml:
<logging traceSpecification="XXX.XXX.*=off=disabled"/>
where XXX.XXX.* is the package where the error was occurred.
Here is a list of all available log levels: http://www-01.ibm.com/support/knowledgecenter/SSCKBL_8.5.5/com.ibm.websphere.nd.doc/ae/utrb_loglevel.html
I understand that you are not asked how to remove these messages from the log file, but you asked should you worry about these messages.
Anyway this log is not of Worklight server, it generated by Liberty server. It means you have something wrong in server configuration.
I found that this messages is because my server.xml configuration file of WebSphere Liberty Profile contains this feature
appSecurity-1.0
And I am not defining any User Registry.
http://pic.dhe.ibm.com/infocenter/rsahelp/v8r5/topic/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/rwlp_feat.html
I am not running the Application Center in this profile and I am securing the Worklight console using properties in the worklight.properties file.
So, the question is can I remove the appSecurity feature?
Add <basicRegistry></basicRegistry> to your server.xml.

System.ServiceModel.ServiceHost, cannot be used for communication because it is in the Faulted state

Receiving this error when trying to work with the queue:
Unexpected error occured: The communication object, System.ServiceModel.ServiceHost, cannot be used for communication because it is in the Faulted state.
at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
How to overcome it?
Update: answer to my solution posted at the end
This problem is due to access rights. Start Visual Studio with administrative rights and the problem will be resolved.
To start Visual Studio with admin rights right click the Visual Studio icon and select "Run As Administrator".
Update: In my case what helped was:
1) enabling trace logs: http://msdn.microsoft.com/en-us/library/ms732023.aspx
2) in the trace log it wrote this:
Binding validation failed because the binding's ExactlyOnce property is set to true while the destination queue is non-transactional. The service host cannot be opened. Resolve this conflict by setting the ExactlyOnce property to false or creating a transactional queue for this binding.
The answer says it all. Created a transactional queue - everything works :) hope it helps people :)
close your solution, Now follow these steps:
1. Right click on the visual studio.
2. Click on Run as Administrator.
3. Now open your solution.
4. Try running it, your problem will be resolved.
From my experience, once a endpoint is in a faulted state, it will not recover on its own and needs to be restarted. There's no way to make that happen from the client side. The host must do it.
On the host side, you can check for a faulted state using code like this:
While True
'broken connection case
If objServiceHost(ii).State <> CommunicationState.Opened Then
Throw New Exception("SynchronizationWS Service Host failed.")
Exit While
End If
Next
Threading.Thread.Sleep(c_SleepTime) 'sleep 1 second before going trying next
End While
We have a higher level program that monitors the heartbeat of our web service (which runs within a windows service) and if the higher level program finds that the heartbeat has stopped, it will recycle the windows service, restarting the WCF web service.
For me it's because the port was already used by another process, I changed the port and the service worked as usual. I knew this by following the trace logs, just follow steps here: https://learn.microsoft.com/en-us/dotnet/framework/wcf/service-trace-viewer-tool-svctraceviewer-exe
The recap:
add this section to the web.config or app.config file:
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="sdt"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "SdrConfigExample.e2e" />
</listeners>
</source>
</sources>
</system.diagnostics>
run the WCF service to reproduce the error.
open SvcTraceViewer.exe tool, I found it in :
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin. It will open the Microsoft Service Trace Viewer window.
Navigate to the log file (File> Open) named "SdrConfigExample.e2e" which was specified in the XML config above, and is located in the root directory. This will list the errors in more detail and you can find the cause of the exception.
*Tip: You can easily and quickly find files on your computer using everything tool.

HTTP Error 404.3 - Not Found" while browsing wcf service on Windows Server 2008(64bit)

I am developing an application based on .Net Framework 3.5 sp1 and hosted on windows server 2008(64bit).
While browsing wcf service (.svc) locally every things is ok but while browsing with full domain URL, it got an error.
local address is like this: http://localhost/MyService.svc
and domain address is like this: http://MySite.ir/MyService.svc
by the way pages (.aspx) and other files work correctly both on localhost and with domain address.
any Idea would be appreciated
Here is detailed error:
HTTP Error 404.3 - Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
Detailed Error Information
Module: StaticFileModule
Notification: ExecuteRequestHandler
Handler: StaticFile
Error Code: 0x80070032
Requested URL: http://MySite.ir:80/MyService.svc
Physical Path: D:\inetpub\vhosts\MySite.ir\httpdocs\MyService.svc
Logon Method: Anonymous
Logon User Anonymous
Please make sure you've activated WCF components from here.
Or alternate and easy way is, go to control panel -> Turn Windows feature on or off -> and make sure you've all the options ticked as mentioned in below screenshot.
You might need to activate each box and accept in case you get errors when activating all features at once
OK, here is the answer:
Go to Handler Mappings | Add Handler Manager --> And then add below information
Request Path: *.svc
Type: System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Name: svc-Integrated
If anyone has this issue on Windows Server 2012, Bill Moon's answer here solved it for me:
"For Windows Server 2012... From the Server Manager, click on Add roles and features, select the appropriate server, then select Features. Under .NET Framework 4.5 Features, you'll see WCF Services, and under that, you'll find HTTP Activation."
I have windows 10 in my laptop and using visual studio 2015 for WCF development. WCF is running fine in visual studio but when hosted in IIS I got the same error.
I checked IIS handler. svc extension was missing. So I tried to add new handler in IIS as suggested by Mori in first answer. I didn't find type "System.ServiceModel.Activation.HttpHandler".
So I opened "Turn windows features On or Off" and installed features as highlighted in screen shot.
This worked for me.
If you're using .Net 4.x, the PublicKeyToken is 31bf3856ad364e35.
However, following this post about installing WCF Services properly in IIS, the handler was set up for me.
I wanted to add this as a comment to the answer but didn't have enough rep for it. I tried running ServiceModelReg and aspnet_regiis.exe with various flags and added HTTP Activation feature but it still didn't work. Even using the Handler mapping UI in IIS didn't work since it could not find System.ServiceModel.Activation.HttpHandler. What finally worked was adding the handler Mori mentions manually to my web.config file.
<system.webServer>
<handlers>
<add name="svc-Integrated" path="*.svc" verb="GET,HEAD,POST,DEBUG" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" modules="ManagedPipelineHandler" scriptProcessor="" resourceType="Unspecified" requireAccess="Script" allowPathInfo="false" preCondition="integratedMode" responseBufferLimit="4194304" />
My project was running .Net 3.5 and IIS 7.5 on Windows 7 and IIS 7.0 on Win Server 2008 R2.
Try unchecking WCF HTTP activations from "Turn Windows featured on or off" window (See here) and re-install by going to
%windir%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\
and execute ServiceModelReg -i