Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stuck at autodiscover #5

Open
exentim opened this issue Feb 18, 2020 · 13 comments
Open

stuck at autodiscover #5

exentim opened this issue Feb 18, 2020 · 13 comments
Assignees
Labels

Comments

@exentim
Copy link

exentim commented Feb 18, 2020

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, List1 redirectionEmailAddresses, Int32& currentHop) bei Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetLegacyUserSettings[TSettings](String emailAddress) bei Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.InternalGetLegacyUserSettings(String emailAddress, List1 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

@xedoc64
Copy link
Collaborator

xedoc64 commented Feb 18, 2020

Did you used the parameter “-allowredirection”?

@exentim
Copy link
Author

exentim commented Feb 19, 2020

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, List1 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.

@exentim
Copy link
Author

exentim commented Feb 19, 2020

In EWSEditor Autodiscover works.
Maybe I have to use impersonation param. How to use the impersonation param correctly?

@exentim
Copy link
Author

exentim commented Feb 19, 2020

Thats what I try:
RemovePrivateFlag.exe -mailbox [email protected] -logonly -foldername "Posteingang" -al
lowredirection -user ycx2459 -impersonate

@xedoc64
Copy link
Collaborator

xedoc64 commented Feb 19, 2020

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).

@exentim
Copy link
Author

exentim commented Feb 19, 2020

Sorry to disturb again :)
it is still not working, trying this:

RemovePrivateFlag.exe -mailbox [email protected] -logonly -foldername "Posteingang" -allowredirection -user [email protected] -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: [email protected]
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: [email protected]
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 [email protected]
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, List1 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!

@exentim
Copy link
Author

exentim commented Feb 20, 2020

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 :)

@xedoc64
Copy link
Collaborator

xedoc64 commented Feb 20, 2020

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?

@xedoc64 xedoc64 self-assigned this Feb 20, 2020
@xedoc64 xedoc64 added the bug label Feb 20, 2020
@xedoc64
Copy link
Collaborator

xedoc64 commented Feb 20, 2020

@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

@exentim
Copy link
Author

exentim commented Feb 20, 2020

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: [email protected]
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: [email protected]
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 [email protected]
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, List1 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]

@exentim
Copy link
Author

exentim commented Feb 20, 2020

part of trace:
....................................................................
//*



[email protected]
http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a




failed: WebException (Die zugrunde liegende Verbindung wurde geschlossen: Unerwarteter Fehler beim Senden..)


Trying to get Autodiscover redirection URL from http://autodiscover.domain.de/autodiscover/autodiscover.xml.


Redirection URL found: 'https://autodiscover.domain.de/autodiscover/autodiscover.xml'


Trying to call Autodiscover for [email protected] on https://autodiscover.domain.de/autodiscover/autodiscover.xml.


POST /autodiscover/autodiscover.xml HTTP/1.1
Content-Type: text/xml; charset=utf-8
Accept: text/xml
User-Agent: ExchangeServicesClient/15.00.0913.015

[email protected] http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a failed: WebException (Die zugrunde liegende Verbindung wurde geschlossen: Unerwarteter Fehler beim Senden..) Trying to get Autodiscover host from DNS SRV record for domain.de. DnsQuery returned error error 'Der DNS-Name ist nicht vorhanden' error code 0x0000232B. No appropriate SRV record was found. No matching Autodiscover DNS SRV records were found.

@exentim
Copy link
Author

exentim commented Feb 20, 2020

@Apoc70
Copy link
Owner

Apoc70 commented Feb 21, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants