Retrieving service account info from IIS logs - wcf

I have a WCF service and I want to check under which service account was a call made to the service two days ago. Can I find that information in IIS logs?
To clarify - another application made a call to my WCF Service and I need to check if that application runs under a service account or is it anonymous.

You can check cs-username field in IIS logs. For anonymous it is -

Related

Developing Windows service using WCF

I have one requirement.
In our company each employee will submit some standard reports using internal portal.
If some employees not submitted report end of the day manager should get notified list of employees not submitted report.
I am using SQL Server database in which one table maintains records the employees submitting reports.
For this i want to use WCF client service.
This service will be installed on the server and client service should send email to Manager at specific time whoever not filled reports.
I know this is very basic requirement and i can do in Windows service. But I want to implement using WCF client service.
Can anyone help me how to do this task using WCF. And can you please refer some links.
I think you want to host the wcf service in windows service instead of IIS.
var serviceHost = new ServiceHost(typeof(YourService));
serviceHost.Open()
Open the service host in the onstart method of windows serice and close on onstop event. And copy the wcf config from wcf service project to windows service project and comment the configuration from wcf service project.

Get/Set the account under which WCF service is hosted

I am hosting my WCF service in a console application. I need to know -
How can I find out under which account and its details this service is hosted?
How can I set the account under which the service must be hosted (this is possible in windows service, but how can this be done in a console application?)
Thanks!
The current user can be found using:
System.Security.Principal.WindowsIdentity.GetCurrent().Name;
There is an interesting impersonation library on github and available via NuGet that should do the trick:
SimpleImpersonation

Periodically run WCF method automatically

I have WCF hosted in IIS. There is a service method which gets the latest Db table record and do some work.
I want my web service to periodically cheks the database table and if there is new record deposited in the table then do the work.
I know how to handle this If my WCF hosted as windows service. But have no idea to do with IIS hosted WPF.
Please advice me.
if u need your wcf service to be invoked at some defined intervals, you can use Quartz Scheduler, where we can specify a particular task to be executed at defined intervals
pls check this link
http://quartz-scheduler.org/documentation/quartz-2.x/tutorials/
It will basically be a Windows Service, with your WCF service reference added to it.
you can just use the Quartz API.

WCF Service - automated or timed action

We have a WCF service, hosted on IIS7.5, that has to fetch some data from an external web service.
Is there some way to schedule this action to be started, in our WCF service, on a regular (timed) basis?
Thanks
Yes, create a Windows service which wakes up every x minutes or hours and makes the call.
The WCF service is not "always on" - it is typically only created when a request comes in and needs to be handled. But you would typically host your WCF service in either IIS, or self-host - which usually already means a Windows Service anyway.
I would recommend VisualCron which can schedule WCF and web service calls (amont other things).
With that tool you can supply dynamic parameters, retrieve output and parse it. If you want you can forward the data to a file, email etc.

How would you communicate a wcf service with a windows service?

Two weeks ago I needed a way to communicate a wcf service with a windows service running on the same computer. The windows service had to get data from a external source and share it with the wcf service (hosted in IIS) who had to give it when a client made a request. I chose to do that with ipc.
I done it and now the windows service is the ipc server and the wcf service is the ipc client. This goes well but I think I made a mistake doing this because to make it run right the windows service must to be executed with the ASPNET account, for this the ASPNET password account must be assigned and when I do that the IIS does not work correctly.
I am thinking on different alternatives, but in all of them the problem persists. Some ideas?
Edit:
What I needed was a system that made public, in a web service hosted in IIS, data gotten through telnet from another old system, what is a little unstable. How the response of this second system was slow I chose to put a process (the windows service) between the web service and the old system. The windows service had to save the data collected from the old system and when the wcf service asked it give it all at once through ipc.
Why does the windows service need to run as the ASPNET user? Is that because you're using an IPC connection that requires authentication from the caller?
Another alternative (if you have control over the windows-service code) would be to make that a WCF service as well (using a ServiceHost in the windows service). The IIS service could connect to the windows service using a NetTcp or NetNamedPipe binding if you need the IPC-like performance.
Why not just create another account with the same permission set of the ASPNET user which both the WCF service and your other service run under? That way, you have control over the password.
Ideally, the windows service should run as a WCF service, that way its easy for the client to communicate with it.
The next question is weather the 'client' needs to be a WCF service. If this client needs to serve other applications then it is appropriate, otherwise it may not be nessesary. I don't know enough about your system, so its up to you to decide what's best!