Open exentim opened 4 years ago
Did you used the parameter “-allowredirection”?
Thanks for the quick response. No I did not. I tried it now with the following result:
2020-02-18 16:30:23,217 [1] ERROR RemovePrivateFlag.Program [(null)] - Connection to mailbox failed
Microsoft.Exchange.WebServices.Data.AutodiscoverLocalException: The Autodiscover service couldn't be located.
bei Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.InternalGetLegacyUserSettings[TSettings](String emailAddress, List1 redirectionEmailAddresses, Int32& currentHop) bei Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetLegacyUserSettings[TSettings](String emailAddress) bei Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.InternalGetLegacyUserSettings(String emailAddress, List
1 requestedSettings)
bei Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetUserSettings(String userSmtpAddress, UserSettingName[] userSettingNames)
bei Microsoft.Exchange.WebServices.Data.ExchangeService.GetAutodiscoverUrl(String emailAddress, ExchangeVersion requestedServerVersion, AutodiscoverRedirectionUrlValidationCallback validateRedirectionUrlCallback)
bei Microsoft.Exchange.WebServices.Data.ExchangeService.AutodiscoverUrl(String emailAddress, AutodiscoverRedirectionUrlValidationCallback validateRedirectionUrlCallback)
bei RemovePrivateFlag.Program.ConnectToExchange(String MailboxID, Boolean allowredirection, String User, String Password, Boolean Impersonisation) in D:\VSREPOSITORIES\RemovePrivateFlag\RemovePrivatFlag\Program.cs:Zeile 313.
In EWSEditor Autodiscover works. Maybe I have to use impersonation param. How to use the impersonation param correctly?
Thats what I try: RemovePrivateFlag.exe -mailbox tim.surname@domain.de -logonly -foldername "Posteingang" -al lowredirection -user ycx2459 -impersonate
The user need to be an SMTP-address. If you use “-user” you need also pass with the option “-password” the password for the user account which should impersonate.
If you don’t pass the “-user” option the program will be use the current credentials of your session (from the command line or the powershell session).
Sorry to disturb again :) it is still not working, trying this:
RemovePrivateFlag.exe -mailbox tim.surname@domain.de -logonly -foldername "Posteingang" -allowredirection -user tim.surname@domain.de -password PasswordX -impersonate
2020-02-19 12:46:18,864 [1] INFO RemovePrivateFlag.Program [(null)] - Application started
2020-02-19 12:46:18,877 [1] DEBUG RemovePrivateFlag.Program [(null)] - Parsing arguments
2020-02-19 12:46:18,878 [1] DEBUG RemovePrivateFlag.Program [(null)] - Arguments:
2020-02-19 12:46:18,878 [1] DEBUG RemovePrivateFlag.Program [(null)] - mailbox: tim.surname@domain.de
2020-02-19 12:46:18,878 [1] DEBUG RemovePrivateFlag.Program [(null)] - Help: False
2020-02-19 12:46:18,879 [1] DEBUG RemovePrivateFlag.Program [(null)] - noconfirmation: False
2020-02-19 12:46:18,879 [1] DEBUG RemovePrivateFlag.Program [(null)] - logonly: True
2020-02-19 12:46:18,879 [1] DEBUG RemovePrivateFlag.Program [(null)] - impersonate: True
2020-02-19 12:46:18,880 [1] DEBUG RemovePrivateFlag.Program [(null)] - allowredirection: True
2020-02-19 12:46:18,880 [1] DEBUG RemovePrivateFlag.Program [(null)] - foldername: Posteingang
2020-02-19 12:46:18,880 [1] DEBUG RemovePrivateFlag.Program [(null)] - User: tim.surname@domain.de
2020-02-19 12:46:18,881 [1] DEBUG RemovePrivateFlag.Program [(null)] - Password: is set
2020-02-19 12:46:18,881 [1] DEBUG RemovePrivateFlag.Program [(null)] - ignorecertificate: False
2020-02-19 12:46:18,881 [1] DEBUG RemovePrivateFlag.Program [(null)] - server URL: using autodiscover
2020-02-19 12:46:18,883 [1] INFO RemovePrivateFlag.Program [(null)] - Connect to mailbox tim.surname@domain.de
2020-02-19 12:51:03,772 [1] ERROR RemovePrivateFlag.Program [(null)] - Connection to mailbox failed
Microsoft.Exchange.WebServices.Data.AutodiscoverLocalException: The Autodiscover service couldn't be located.
bei Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.InternalGetLegacyUserSettings[TSettings](String emailAddress, List1 redirectionEmailAddresses, Int32& currentHop) bei Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetLegacyUserSettings[TSettings](String emailAddress) bei Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.InternalGetLegacyUserSettings(String emailAddress, List
1 requestedSettings)
bei Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetUserSettings(String userSmtpAddress, UserSettingName[] userSettingNames)
bei Microsoft.Exchange.WebServices.Data.ExchangeService.GetAutodiscoverUrl(String emailAddress, ExchangeVersion requestedServerVersion, AutodiscoverRedirectionUrlValidationCallback validateRedirectionUrlCallback)
bei Microsoft.Exchange.WebServices.Data.ExchangeService.AutodiscoverUrl(String emailAddress, AutodiscoverRedirectionUrlValidationCallback validateRedirectionUrlCallback)
bei RemovePrivateFlag.Program.ConnectToExchange(String MailboxID, Boolean allowredirection, String User, String Password, Boolean Impersonisation) in D:\VSREPOSITORIES\RemovePrivateFlag\RemovePrivatFlag\Program.cs:Zeile 313.
[Ended]
Any tipps? When to set param ignorecertificate and how to set param server URL? Best regards!
can this help? https://stackoverflow.com/questions/11477255/read-email-using-exchange-web-services
Maybe adding the version is needed like in EWSEditor? var service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
The problem lies in line 313 accordng to output above. service.AutodiscoverUrl(MailboxID,RedirectionCallback); // AutodiscoverUrl(String, AutodiscoverRedirectionUrlValidationCallback)
What does your comment mean for the second part?
Please help :)
I've tested the version now against O365 and an Exchange 2016. Here it works flawlessly. Against an Exchange 2019 i receive the same error message. Requesting the version with the service creation doesn't remove the error. Against which Exchange version to you running the tool?
@exentim Could you please try the following build? This is working in my test lab. Requirements for .NET have changed (now 4.8). Release.zip
Hello, I tried your build. We have ExchangeVersion.Exchange2013_SP1
2020-02-20 21:38:43,533 [1] DEBUG RemovePrivateFlag.Program [(null)] - Parsing arguments
2020-02-20 21:38:43,533 [1] DEBUG RemovePrivateFlag.Program [(null)] - Arguments:
2020-02-20 21:38:43,534 [1] DEBUG RemovePrivateFlag.Program [(null)] - Mailbox: tim.surname@domain.de
2020-02-20 21:38:43,534 [1] DEBUG RemovePrivateFlag.Program [(null)] - Help: False
2020-02-20 21:38:43,535 [1] DEBUG RemovePrivateFlag.Program [(null)] - NoConfirmation: False
2020-02-20 21:38:43,535 [1] DEBUG RemovePrivateFlag.Program [(null)] - LogOnly: True
2020-02-20 21:38:43,535 [1] DEBUG RemovePrivateFlag.Program [(null)] - Impersonate: True
2020-02-20 21:38:43,536 [1] DEBUG RemovePrivateFlag.Program [(null)] - AllowRedirection: True
2020-02-20 21:38:43,536 [1] DEBUG RemovePrivateFlag.Program [(null)] - Trace fort EWS: True
2020-02-20 21:38:43,536 [1] DEBUG RemovePrivateFlag.Program [(null)] - Archive: False
2020-02-20 21:38:43,537 [1] DEBUG RemovePrivateFlag.Program [(null)] - foldername: Posteingang
2020-02-20 21:38:43,537 [1] DEBUG RemovePrivateFlag.Program [(null)] - User: tim.surname@domain.de
2020-02-20 21:38:43,537 [1] DEBUG RemovePrivateFlag.Program [(null)] - Password: is set
2020-02-20 21:38:43,538 [1] DEBUG RemovePrivateFlag.Program [(null)] - ignorecertificate: True
2020-02-20 21:38:43,538 [1] DEBUG RemovePrivateFlag.Program [(null)] - Server URL: using autodiscover
2020-02-20 21:38:43,538 [1] WARN RemovePrivateFlag.Program [(null)] - Ignoring SSL error because option -ignorecertificate is set
2020-02-20 21:38:43,540 [1] INFO RemovePrivateFlag.Program [(null)] - Connect to mailbox tim.surname@domain.de
2020-02-20 21:43:30,502 [1] ERROR RemovePrivateFlag.Program [(null)] - Connection to mailbox failed
Microsoft.Exchange.WebServices.Data.AutodiscoverLocalException: The Autodiscover service couldn't be located.
bei Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.InternalGetLegacyUserSettings[TSettings](String emailAddress, List1 redirectionEmailAddresses, Int32& currentHop) bei Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetLegacyUserSettings[TSettings](String emailAddress) bei Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.InternalGetLegacyUserSettings(String emailAddress, List
1 requestedSettings)
bei Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetUserSettings(String userSmtpAddress, UserSettingName[] userSettingNames)
bei Microsoft.Exchange.WebServices.Data.ExchangeService.GetAutodiscoverUrl(String emailAddress, ExchangeVersion requestedServerVersion, AutodiscoverRedirectionUrlValidationCallback validateRedirectionUrlCallback)
bei Microsoft.Exchange.WebServices.Data.ExchangeService.AutodiscoverUrl(String emailAddress, AutodiscoverRedirectionUrlValidationCallback validateRedirectionUrlCallback)
bei RemovePrivateFlag.Program.ConnectToExchange(String MailboxID, Boolean allowredirection, String User, String Password, Boolean Impersonation, Boolean Trace)
[Ended]
part of trace: .................................................................... //*
Have you checked the Service Principal Name (SPN) following this post? https://techcommunity.microsoft.com/t5/exchange-team-blog/how-to-enable-kerberos-authentication-for-accessing-exchange-in/ba-p/605166 Or this post? https://medium.com/@tkolber/https-medium-com-tkolber-configure-kerberos-authentication-with-exchange-2019-72293aa234c
Can you please send a full trace (anonymized) to thomas@mcsmemail.de?
Hello Thomas,
what can I do to solve this?
2020-02-18 15:09:41,108 [1] ERROR RemovePrivateFlag.Program [(null)] - Connection to mailbox failed Microsoft.Exchange.WebServices.Data.AutodiscoverLocalException: Autodiscover blocked a potentially insecure redirection to https://autodiscover.yxc.de/autodiscover/autodiscover.xml. To allow Autodiscover to follow the redirection, use the AutodiscoverUrl(string, AutodiscoverRedirectionUrlValidationCallback) overload. bei Microsoft.Exchange.WebServices.Data.ExchangeService.DefaultAutodiscoverRedirectionUrlValidationCallback(String redirectionUrl) bei Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.CallRedirectionUrlValidationCallback(String redirectionUrl) bei Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.TryLastChanceHostRedirection[TSettings](String emailAddress, Uri redirectionUrl, TSettings& settings) bei Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.InternalGetLegacyUserSettings[TSettings](String emailAddress, List
1 redirectionEmailAddresses, Int32& currentHop) bei Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetLegacyUserSettings[TSettings](String emailAddress) bei Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.InternalGetLegacyUserSettings(String emailAddress, List
1 requestedSettings) bei Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetUserSettings(String userSmtpAddress, UserSettingName[] userSettingNames) bei Microsoft.Exchange.WebServices.Data.ExchangeService.GetAutodiscoverUrl(String emailAddress, ExchangeVersion requestedServerVersion, AutodiscoverRedirectionUrlValidationCallback validateRedirectionUrlCallback) bei Microsoft.Exchange.WebServices.Data.ExchangeService.AutodiscoverUrl(String emailAddress, AutodiscoverRedirectionUrlValidationCallback validateRedirectionUrlCallback) bei Microsoft.Exchange.WebServices.Data.ExchangeService.AutodiscoverUrl(String emailAddress) bei RemovePrivateFlag.Program.ConnectToExchange(String MailboxID, Boolean allowredirection, String User, String Password, Boolean Impersonisation) in D:\VSREPOSITORIES\RemovePrivateFlag\RemovePrivatFlag\Program.cs:Zeile 317.Danke, viele Grüße