Exchange 2007 The Remote Server Returned An Error 401 Unauthorized
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies remote server returned an error 401 unauthorized in c# of this site About Us Learn more about Stack Overflow the company Business remote server returned an error 401 unauthorized iis 7 Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask the remote server returned an error 401 unauthorized sharepoint client object model Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign the remote server returned an error 401 unauthorized wcf up Exchange Web Service API and 401 unauthorized exception up vote 12 down vote favorite 1 When I try sending email using the EWS API, I get the following error: (in message.Send();) The request failed. The remote server returned an error: (401) Unauthorized. My code is the following: ExchangeService exchangeService = new ExchangeService(ExchangeVersion.Exchange2007_SP1); //WebService Uri try { exchangeService.Url = new Uri("https://exchangeserver/ews/exchange.asmx"); }
The Remote Server Returned An Error 401 Unauthorized Httpwebrequest
catch (Exception ex) { throw new Exception(string.Format("WebService Uri:" + ex)); } //Credentials try { exchangeService.Credentials = new WebCredentials("user@domain", "pwd", "domain"); } catch (Exception ex) { throw new Exception(string.Format("Credentials:" + ex)); } //Send a mail try { EmailMessage message = new EmailMessage(exchangeService); message.Subject = "Test"; message.Body = "Test"; message.ToRecipients.Add("destination@domain"); message.Save(); message.Send(); } catch (Exception ex) { throw ex; } I read other posts on this site concerning this issue but they couldn't resolve my issue. c# exchangewebservices http-status-code-401 exchange-server-2007 unauthorized share|improve this question edited May 25 '14 at 8:04 Shadow Wizard 49.1k1385130 asked Nov 22 '12 at 17:07 GwenGuts 1251110 You saved my career by asking this question! –Chookoos Mar 18 at 3:47 My pleasure :) !! –GwenGuts Mar 21 at 15:47 add a comment| 2 Answers 2 active oldest votes up vote 19 down vote accepted +100 Try changing this: exchangeService.Credentials = new WebCredentials("user@domain", "pwd", "domain"); into this: exchangeService.Credentials = new WebCredentials("user", "pwd", "domain"); Sometime the Login credentials depends on how Exchange/Active Directory it's configured. It could be user@domain or domain\user share|improve this answer answered Nov 22 '12 at 17:22 Carlos Land
| My Forums | Address Book | Member List | Search | FAQ | Ticket List | Log Out (401) Unauthorized Error when running Test-OutlookWebServices Users viewing
The Remote Server Returned An Error 401 Unauthorized Webrequest
this topic: none Logged in as: Guest Tree Style Printable Version the remote server returned an error 401 unauthorized twitter oauth All Forums >> [Microsoft Exchange 2007] >> Installation >> (401) Unauthorized Error when running Test-OutlookWebServices Page: [1] Login Message << system net webexception the remote server returned an error 401 unauthorized Older Topic Newer Topic >> (401) Unauthorized Error when running Test-OutlookWebSe... - 15.Aug.2009 2:03:43 PM SeanRatVAOpera Posts: 5 Joined: 15.Aug.2009 Status: offline Org Set up: CCR Mailbox Server Cluster http://stackoverflow.com/questions/13517323/exchange-web-service-api-and-401-unauthorized-exception on WS 2008 CAS/HT Server on WS 2003 R2 Let me know what else you need and thanks in advance for your help. I am getting the following outputwhen I run Test-OutlookWebServices on the CAS/HT server: [PS] C:\>Test-OutlookWebServices | fl Id : 1003 Type : Information Message : About to test AutoDiscover with the e-mail address E2k7.Test@domain.org. Id : 1007 Type : Information Message http://forums.msexchange.org/(401)_Unauthorized_Error_when_running_Test-OutlookWebServices/m_1800515392/tm.htm : Testing server voa-nor-w.vaopera.net with the published name https://owa.domain.net/EWS/Exchange.asmx & https://owa.domain.org/EWS/Exchange.asmx. Id : 1019 Type : Information Message : Found a valid AutoDiscover service connection point. The AutoDiscover URL on this object is https://owa.domain.net/Autodiscover/Autodiscover.xml. Id : 1013 Type : Error Message : When contacting https://owa.domain.net/Autodiscover/Autodiscover.xmlreceived the error The remote server returned an error: (401) Unauthorized. Id : 1006 Type : Error Message : The Autodiscover service could not be contacted. Post #: 1 Featured Links* RE: (401) Unauthorized Error when running Test-OutlookW... - 15.Aug.2009 2:29:38 PM jveldh Posts: 2335 Joined: 12.Apr.2008 From: The Netherlands Status: offline Hi, Did you check this blog, it helped for me: http://www.exchange-genie.com/2007/07/401-error-when-attempting-test-outlookwebservices/ _____________________________Best regards, Johan Veldhuis Visit my Exchange blog (in reply to SeanRatVAOpera) Post #: 2 Errors when running Test-OutlookWebServices - 15.Aug.2009 4:03:54 PM SeanRatVAOpera Posts: 5 Joined: 15.Aug.2009 Status: offline That LSA DWord add to the registry got rid of the 401 error. Now I have to track down why I'm getting the following output: [PS] C:\>Test-OutlookWebServices | fl Id : 1003 Type : Information Message : About to test AutoDiscover with the e-mail address E2k7.Test@vaopera.org. Id :
JoshiNovember 29, 20111 0 0 0 A customer recently reported a problem to Microsoft where they were dicovering that their exchange web services were unable to connect to some https://blogs.msdn.microsoft.com/pareshj/2011/11/29/exchange-web-services-fail-using-impersonation-to-access-mailboxes/ mailboxes. Often support engineers need to ask probing questions about what recently happened http://www.codetwo.com/userguide/exchange-migration/target-connection-settings/target-verify-exchange-connection.htm in the companys organisation, what recent tools and software updates that were applied and some back ground information about their network topology is neeed to be able to isolate the problem at hand. In this customers case, they had recently performed a migration from 1900 exchange 2003 mailbox accounts to exchange remote server 2010 mailboxes. Some of these accounts were unable to be accessed using impersonation from exchange web servicesI wanted to document some tools and questions that might be worth asking to try and help isolate the root cause and be able to find an appropriate troubleshooting path. The core issue was related to impersonation code not working in customers EWS code to access certain remote server returned mailboxes. these articles are a good reference to determine how you can get configure impersonation to work with EWS and ensure the accounts you are using have the appropriate privileges/roles.scope to perform the taskhttp://msdn.microsoft.com/en-us/library/bb204095.aspx Using Exchange Impersonationhttp://msdn.microsoft.com/en-us/library/bb204088.aspx Working with impersonation by using the EWS Managed APIhttp://msdn.microsoft.com/en-us/library/dd633680(EXCHG.80).aspx The soap test tool is a good tool to determine (outside of yoru code) if your EWS code is working correctly, you can find this here -http://soaptestapp.codeplex.com/ There is a brief introduction here: http://soaptestapp.codeplex.com/wikipage?title=Introduction With the call succeeding we can rule out if it was related to the customers code so we wanted to know what ServiceError reports back from EWS http://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.serviceerror(v=exchg.80).aspxIn the SOAP requests in your code can you add.. svc.TraceEnabled = true;svc.TraceFlags |= TraceFlags.All; more information here - Tracing EWS requestshttp://msdn.microsoft.com/en-us/library/dd633676(v=EXCHG.80).aspxThis will add additional logging information to the SOAP data chck that the customer was using the latest EWS API libraries(14.02.0051.000)http://www.microsoft.com/download/en/details.aspx?id=13480 It's always good to understand what the underlying SOAP requests are so using tools such as netmon and fiddler is always good to use to determine what web service errors you may be seeing . These mailboxes were exchange 2
Update or upgrade Reinstall or move How to uninstall Quick guide to migration Migration walkthrough from Exchange 2003 from Exchange 2007 from Exchange 2010 from Exchange 2013 from IMAP source How to Connect to Source Exchange Connect to IMAP Source Configure a Job Configure Scheduler Automatch mailboxes Customize settings Troubleshooting Source server connection IMAP connectivity Data Provider service configuration Exchange Server connectivity Exchange Server Administrator's group membership Target server connection Exchange Server's name vs. its IP address Exchange Server connectivity Exchange Server Administrator's impersonation rights Exchange Server PowerShell console connectivity Monitoring and diagnostics Dashboard and Jobs Reports Log files Licensing Trial version Activation License Agreement Upgrade to version 2.x Knowledge Base Feedback Program’s homepage Troubleshooting Target Exchange Server connectivity This test checks if the program can establish a connection to the target server. The program tries to access administrator's mailbox with EWS (Exchange Web Services) API. Next it tries to enumerate mailbox's Inbox folder. Fig. 1.Failed to connect to on-premises Exchange Server. Tip To minimize the risk of connection errors, we advise to enable trust relationship between the Source and Target server. Learn more about creating a forest trust on Windows Server 2003 and on Windows Server 2008 and newer. Study the examples below that show the most common source server connectivity issues: The request failed. The remote server returned an error: (401) Unauthorized. The error above indicates that Admin's credentials entered in the previous step are incorrect or of the non-administrative user. To fix the problem make sure to enter the Administrator's credentials. Learn more about this error The request failed. Unable to connect to th