Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 587
  • Last Modified:

C# EWS Exchange 2010 issue

Experts,

I have an issue regarding deploying (to a test server) an application that makes use of enterprise web services.
I have a mailing function that sends emails to clients based on the user that is logged into the system. However, these emails are required to go through Exchange.
This is where I am having an issue. The functionality is there, it does work, but for some reason, it uses the identity the app pool to send the email.

e.g. App pool is running as Domain\BloggsF.  

The email is getting sent as if it was from Bloggs F.

Can some one advise on

a) Why it would do this,
b) What the solution could be?

Regards
0
S-Unit
Asked:
S-Unit
  • 5
  • 4
1 Solution
 
LeeDerbyshireCommented:
Hard to say without seeing the code, but I don't see how EWS could even do that without Bloggs F actually having a mailbox in the first place, and I assume that your AppPool account doesn't have a mailbox?

What authentication methods do you have enabled on your EWS vdir on the target CAS server?
0
 
S-UnitAuthor Commented:
The AppPool account is running as a specific user (in this case the an administrator called Fred Bloggs) and therefore the person does have an email address (not ideal).

I've attached a Sample.cs file, which I'm using.

The code is then used like this...

var exchange = new ExchangeHelper();
            var service = exchange.InitialiseExchangeService(userEmailAddress);
            foreach (var client in clientData)
            {
                if (!string.IsNullOrEmpty(client.EmailAddress))
                {
                    try
                    {
                        data = exchange.CreateEmailAndSave(service, userEmailAddress, new List<string>() { client.EmailAddress }, null, null, subject, body, null);
                       
                    }
                    ...........

Is this likely to be an issue in the way the account on the web server
Sample.cs
0
 
LeeDerbyshireCommented:
I reckon the value of userEmailAddress is going to determine who the messages appear to come from, since that value is used to tell EWS which mailbox to connect to.  But I can't see anywhere in the code that it gets assigned a value.  Is there anywhere outside the parts you've already posted where it gets assigned?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
S-UnitAuthor Commented:
Yes,

That value (email address) is coming from data that is fetched from the database (logged on user's) when the user logs on. This is then stored as static data and, as in this case, passed as a parameter in a method.
I've checked and it does have a value assigned to it. This is the thing that's puzzling me. If a value is assigned from user A, why is it that the email sent is coming from the account that the AppPool is running under.
0
 
LeeDerbyshireCommented:
I've not heard of it doing that, but I think it would be an interesting test to see if you can run the app pool under one of the built-in ids (network service), at least for a test.  The EWS vdir has anonymous access enabled by default (I think), and if it find itself running under an app pool id with a mailbox, it might just prefer to take the easy way out and use that.
0
 
S-UnitAuthor Commented:
Sorry for the late reply. I've been off work with the dreaded man flu. I'll try that and get back to you. Thanks.
0
 
LeeDerbyshireCommented:
No problem, I hope you feel better soon.
0
 
S-UnitAuthor Commented:
Sorry, I will be back at work to try this solution tomorrow.
0
 
S-UnitAuthor Commented:
Thanks a lot Lee. Though I haven't solved the issue, I know now why it occurs. You were pretty much bang on. The service will use the App pool credentials. More info can be found on this post

http://social.technet.microsoft.com/Forums/en-NZ/exchangesvrdevelopment/thread/bb916d27-c903-4ec4-b623-1a29078ad9ff
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now