Solved

Source Code to connect Outlook from ASP.Net Web Application

Posted on 2004-04-28
8
1,370 Views
Last Modified: 2007-12-19
Hi,

I am looking for a source code to read contacts in Outlook from a Web application written in C#.

I have no problem to write a program in C# Windows form that access outlook.

But when I do the same programming code in a web application, the web application doesn't work for authorizations reasons.

Can you help me to solve this problem?

Thank you very much,

Olivier
0
Comment
Question by:olivierverdin
8 Comments
 
LVL 1

Expert Comment

by:iclemartin
ID: 10943879
Is your website using authentication or anonymous access? If anonymous then your code is trying to establish a MAPI session using the account assigned (IUSR_*).

One way to fix this is change the anonymous user to a new account. Log into this new account and set up a default email profile.
0
 
LVL 5

Expert Comment

by:danielsonchris
ID: 10943972
After reading your question the first thing that came to mind was a program I wrote in C++ a few years back that I ended up using tokens to elevate my user levels.  With that said, I was curious how I'd do that in .Net without having to use the Interop.  Here is a pretty sweet link... I think you may find what you need in this page.  

http://msdn.microsoft.com/msdnmag/issues/01/11/security/default.aspx

Best regards,
Chris
0
 
LVL 1

Expert Comment

by:jangeador
ID: 10945814
What you need to do is to enable impersonation in the web config. I had a similar situation and I created an account with the proper permissions in the domain, and then I used forms based security because once they passed the security they have the proviledges of the impersonated user.

Create your user and then add this line to your web.config

<identity impersonate="true"
          userName="domain\user"
          password="password" />

Remember that once your users are on your application they will execute their code with the user credentials. If you want to force each user to use their own credentials then only use this line:

<identity impersonate="true" />

I had to use a user account because the things I wanted my users to do required elevated privileges that I did not want to give them, so I just had them impersonate as a user with those privileges.

Hope this helps,

jangeador
0
 
LVL 1

Expert Comment

by:jangeador
ID: 10945825
Oh, one more thing, if you use impersonation you need to turn on one of the authentication methods in IIS, either Basic Challenge Response, or Integrated Windows Security.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:olivierverdin
ID: 10946903
I need to force each user to use their own credentials so I will use <identity impersonate = "true" />

but how do you turn on one of the authentication methods in IIS?  I did'nt find these options in IIS.

Thanks for your help,

Olivier
0
 
LVL 1

Accepted Solution

by:
jangeador earned 500 total points
ID: 10950478
In the IIS management right click on your site, then go to properties, then go to the "Directory Security" tab, and then under the "Anonymous Access and Authentication Control" you can find the options mentioned above.

Just remember, by default all processes run under the LocalServer\ASPNET account. you need to ensure that all your users belong to a security group which has access to all the resources on your site, such as sql server or any other resource.

Here is a good article that perhaps you should check out.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsent7/html/vxconImpersonation.asp
0
 

Author Comment

by:olivierverdin
ID: 10952820
Ok, I will read this article and try to understand.

I changed the authorizations of IIS.  Now the application is not crashing but it is waiting for the response of the web server and it stays like this forever!

Any idea of the problem?

Thanks,

Olivier
0
 
LVL 1

Expert Comment

by:jangeador
ID: 10953556
I will try to put a user information in the impersonation line just to test it. I am really not sure what information is waiting for. have you tried debugging to see which line is getting stuck on?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A short article about a problem I had getting the GPS LocationListener working.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now