Receiving the list of contacts from Outlook - outlook

Microsoft.Office.Interop.Outlook.Application outlookObj;
outlookObj = new Microsoft.Office.Interop.Outlook.Application();
At start of the program gives out a mistake
{ "It wasn't succeeded to receive factory of the class COM for a component with CLSID {0006F03A-0000-0000-C000-000000000046} because of the following mistake: 80080005 Mistake at implementation of the appendix server (An exception of HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE))." }
In what the mistake consists?

CO_E_SERVER_EXEC_FAILURE usually means that your code and Outlook are running in different security contexts. Is either app running with elevated privileges (run as administrator)? Is your app running as a service?

In case if you run the code on the server-side or from any non-interactive client:
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution.
You can read more about that in the Considerations for server-side Automation of Office article.

Related

How can a Windows command be executed client side in a web application?

Are there ways to call a Windows command (ie: exe file) from a web application on the browser/client-side? Perhaps by installing a browser plug-in or client-side application? I realize web browsers are sandboxed really well, but this is just an internal app in our department, so this is putting all security risks aside for now. If so, how can this be done?
This is being used to link directly to a Windows application which hosts call tickets from a web application, to the specific call ID.
I believe you have to install a plugin in the browser. That would be an ActiveX object for IE or an NPAPI plugin for all the other browsers.
You can't just set aside the security implications because it's an internal app. If you install a browser plugin that lets a page issue arbitrary commands, then you have to worry about other pages trying to take advantage of that plugin. A common precaution is to have the plugin check the domain of the page (e.g., to make sure it's from your corporate domain) before performing the action. This is commonly called site-locking.
Another security approach is not to have the plugin relay arbitrary commands from the page but rather perform one of a limited set of commands built into the plugin itself. This can reduce the attack surface tremendously.

Is it possible to deploy an out-proc COM server on Windows Azure and alter its activation permission?

I need to consume an out-proc COM server from both a worker role and a web role in a Windows Azure application. One step I'm almost sure I'll need to do is to alter the access permissions for the COM server - grant "local launch" and "local activation" permissions for the predefined user under which roles code executes.
So far I found there's DCOMPERM utility in Windows SDK samples which contains code that I guess would do that. So I could write similar code and package it into either a separate executable or into the COM registration code of the COM server and run that code from a role start-up task. That's not trivial, but certainly doable.
I only have one major concern before I start.
Are there any reasons why I can't do that? Maybe using out-proc COM servers is not allowed on Windows Azure or something? Are there any such limitations?
Are there any reasons why I can't do that? Maybe using out-proc COM servers is not allowed on Windows Azure or something? Are there any such limitations?
It's not something I've personally done, but if you can install a COM+ server running in a shell exe, then I think you should be able to do what you want - see this recent blog post http://michaelwasham.com/2011/05/15/deploying-a-com-servicedcomponent-to-windows-azure/
I don't think you will hit limitations - but I think you will hit a fair few problems along the way - good luck.

Setup kerberos delegation automatically

I have a web app that uses some backend servers (UNC, HTTP and SQL). To get this working I need to configure ServicePrincipalNames for the account running the IIS AppPool and then allow kerberos delegation to the backend services.
I know how to configure this through the "Delegation" tab of the AD Users and Computers tool.
However, the application is going to be deployed to a number of Active Directory environments. Configuring delegation manually has proved to be error prone and debugging the issues misconfiguration causes is time consuming. I'd like to create an installation script or program that can do this for me.
Does anyone know how to script or programmatically set constrained delegation within AD?
Failing that how can I script reading the allowed services for a user to validate that it has been setup correctly?
OK, after much digging on the internet and some testing, I've got a way forward.
The following code is c#.
Setting an SPN for a user or computer can be achieved via the setspn utility.
Alternatively, the following C# code can do the same:
DirectoryEntry de = new DirectoryEntry("LDAP://"+usersDN);
if (!de.Properties["servicePrincipalName"].Contains(spnString))
{
de.Properties["servicePrincipalName"].Add(spnString);
de.CommitChanges();
}
To set constrained delegation:
if (!de.Properties["msDS-AllowedToDelegateTo"].Contains(backendSpnString))
{
de.Properties["msDS-AllowedToDelegateTo"].Add(backendSpnString);
de.CommitChanges();
}
If the user has had non-constrained delegation enabled, you may need to turn this off before enabling constrained - but I didn't fully test this scenario.

What is the difference among Web Service, WCF and Window Service?

I got a lot of theoretical answers from Google that WCF is better than Web Service etc. etc. But I want to know from the programming and implementation point of view. I am very new to coding and want to know that how do we implement all three of these technologies? How are they different and in which scenario we should used which technologies?
Thank you in advance.
A web service is an API that is hosted for access via a network connection - often the internet - and usually accessed over HTTP (or HTTPS).
WCF is a Microsoft .NET development framework that can be used to implement web services. That is, WCF-services are a subset of all web-services.
Windows services are a separate beast entirely: they are long-running programs that run on your local Windows machine, typically with no user interaction and on system accounts. They are used to handle many things in Windows, from low-level driver functionality to software updates.
You're really comparing apples and oranges. A web service is simply a program that you can "call" using the HTTP protocol. Typically, HTTP requests sent to the service contain some XML describing the method called and any parameters. The response from the service likewise contains XML with the return value and any output parameters. It's a little more complicated than this, but it gives you the basic idea.
Windows Communication Foundation (WCF) is a framework for building network services. You can use this framework to build web services if you wish. I suspect that what's tripping you up are the various Visual Studio project templates. You have one for WCF services and one for web services. The web service template builds a web service that runs inside of IIS. The WCF template gives you far more flexibility (you can make a web service as a stand-alone application, for example), but it is far more complicated.
If you're just beginning, I'd start with web service template and IIS-based web services.
MSDN is always a good reference:
Web Service Tutorial:
http://msdn.microsoft.com/en-us/library/8wbhsy70%28VS.80%29.aspx
WCF Tutorial:
http://msdn.microsoft.com/en-us/library/ms734712.aspx
I think its always easier to learn by doing.
Good luck

Install Windows service for a Sharepoint application

I have written a Windows service to send mails to users in a Sharepoint list based on some condition.
The development server is a stand-alone Sharepoint installation and the Windows service works fine. But,the Production environment has the application(Sharepoint) and Database(SQL) residing on different servers.
So when the Windows service tries to open the list it says " Cannot open database "WSS_Content80" requested by the login. The login failed."
Pease let me know how to proceed.I am struck with this issue for a long time now..
To solve the Issue quick and Dirty way what you can do is grant permission to the Content Database of your SharePoint application for the User in Which Windows Services Run.
But you want to do it in a neat way I recommend you to write a Timer Job for SharePoint. Here not only does the Permission is taken care automatically but you can also deploy it to multiple Web Application if you want it and manage it easily.
The Best Article on the Subject is here MSDN or AC Article.
Another possible answer is to check which account your service is running as. Running it as a more privileged user like the account that is acting as your app pool would work.
Another possible tact is to look into SPSecurity.RunWithElevatedPrivledges method.

Resources