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

Remote Exchange Connections #27

Open
cpdonohue opened this issue Jan 22, 2020 · 9 comments
Open

Remote Exchange Connections #27

cpdonohue opened this issue Jan 22, 2020 · 9 comments
Labels
bug Something isn't working

Comments

@cpdonohue
Copy link

I'm trying to use WebJea to connect to ExchangeOnline using the new Powershell v2 cmdlets.

I keep getting an error of "Access denied." The same credentials work if run from powershell directly on the server.
Anybody have suggestions?

@markdomansky
Copy link
Owner

How are you storing the credentials so they're accessible by the IIS RunAs account?

@markdomansky markdomansky added the question Further information is requested label Jan 27, 2020
@cpdonohue
Copy link
Author

The credentials are in a file that the application pool user has access to. The failure isn't coming at reading the file. Its coming at the connection.
Connect-ExchangeOnline -Credential $UserCredential
fails with Access Denied. But works when run locally.

@markdomansky
Copy link
Owner

How are the credentials stored in the file? Clear text or using ConvertFrom-SecureString. ConvertFrom-SecureString generates a string that can only be decrypted by the same user on the same machine. You would have to log in as the RunAs account to do it that way. What I've done in the past is store credentials using the localmachine account.

This article has instructions how, you just replace "CurrentUser" with "LocalMachine". It's certainly not best practice, but it's worked for me.

@cpdonohue
Copy link
Author

In the very not recommended category... the password is in plain text. The code looks like:
$Pass = get-content file.pw | convertto-securestring -asplaintext -force
$Credential = get-credential (new-object -typename System.Management.Automation.PSCredential -argumentlist "user@domain.com",$Pass)
Connect-ExchangeOnline -credential $credential
That last line returns access denied.

@markdomansky
Copy link
Owner

Sorry for the delay in getting back to you. Have you confirmed that get-content is actually reading the file? It may still be a permissions issue on the file itself.

@ksccare
Copy link

ksccare commented Jul 9, 2020

Did you get anywhere with the Exchangev2 cmdlets?

i was able to get authentication working using the Certificate based auth with a cert in my gMSA cert store using the preview cmdlets (as noted here: https://techcommunity.microsoft.com/t5/exchange-team-blog/modern-auth-and-unattended-scripts-in-exchange-online-powershell/ba-p/1497387

The connect itself works fine, but none of the cmdlets work in WebJea. I get this response.

System event notifications are not supported under the current context. Server processes, for example, may not support global system event notifications.
at <ScriptBlock>, C:\WebJEA\Scripts\Test.ps1: line 45
    + CategoryInfo          : NotSpecified: (:) [Get-EXOMailbox], InvalidOperationException

The same cmdlets work fine in a psexec session running under the gMSA account.

@stale
Copy link

stale bot commented Sep 7, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Sep 7, 2020
@markdomansky markdomansky added bug Something isn't working and removed question Further information is requested wontfix This will not be worked on labels Sep 7, 2020
@markdomansky
Copy link
Owner

Marking as a bug for the moment so that stalebot doesn't kill it. I haven't had much opportunity to look into this.

@ksccare
Copy link

ksccare commented Sep 7, 2020

I haven't looked at this for a while, we did a workaround.

its not pretty, but for those who may need these cmdlets in Webjea at this time, we ended up using webjea to call a scheduled task which ran the cmdlets with the inputs and then had the site read the output back to the user. It worked for our requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants