OfficeDev / ews-managed-api

Other
584 stars 316 forks source link

If EWS is discontinued, what about on-premise systems ? #202

Open ststeiger opened 6 years ago

ststeiger commented 6 years ago

In the readme "you" write, EWS is superseeded by Microsoft Graph. On the website, "you" then go on to write that it's recommended to migrate to Microsoft Graph to access Exchange Online data.

But what about on-premise exchange installations ? Since it would be unintelligent to build new interfaces upon a deprecated system... is there Microsoft Graph for on premise ?

You do not seriously believe we will all be that stupid to migrate OUR email systems to YOUR cloud, where we have absolutely NO CONTROL over it, nor about what "you" do with it, and how to get OUR data back, do you ?

(Not that I would be very trusting in the integrity (not to mention quality) of "your" on-premise systems either, or about email altogether.)

sivdonepudi commented 6 years ago

MS says

These plans apply only to the cloud-based Office 365/Exchange Online products; there are no changes to EWS capabilities of on-premises Exchange products

More Here

ststeiger commented 6 years ago

How does it not affect on-premises Exchange products if the API is discontinued/not-updated-anymore and new features/capabilities aren't added ? Sound like bs.

MichelZ commented 6 years ago

To be fair - when was the last time a new feature was actually added? So this situation has been going on for a while now. At least if Graph & EWS would have feature parity, I could understand the decision (Online), but they don't even support all current EWS features...

But yeah, I guess that's the "new microsoft" now.

ststeiger commented 6 years ago

At least if Graph & EWS would have feature parity, I could understand the decision (Online), but they don't even support all current EWS features...

Ah well, that is good to know. So for the time being, I don't miss out on anything you say.

poizan42 commented 5 years ago

@yinaa was the one to add the statement to the readme so maybe they know something?

ststeiger commented 5 years ago

This is really all you need to know.
This and how to get the PowerShell-connection to work (firewall, port-forwarding, permission for user, service running, etc.).

Requires nuget System.Management.Automation.


namespace PowerShellCore
{

    class Program
    {

        public static System.Security.SecureString String2SecureString(string pw)
        {
            System.Security.SecureString secString = new System.Security.SecureString();
            foreach (char c in pw)
            {
                secString.AppendChar(c);
            }

            return secString;
        }

        public enum MailboxType
        {
            Room,
            Equipment,
            Shared,
            Regular
        }

        // WinRM
        // https://www.faqforge.com/windows/create-powershell-session-remote-computer/
        // https://docs.microsoft.com/en-us/powershell/exchange/exchange-server/connect-to-exchange-servers-using-remote-powershell?view=exchange-ps
        // Remove-Mailbox -Identity "John Rodman" -Permanent $true
        public static async System.Threading.Tasks.Task CreateMailbox()
        {
            string userName = SecretManager.GetSecret<string>("loginDN");
            string password = SecretManager.GetSecret<string>("loginDnPW");

            string powerShellUri = "https://webmail.mycompany.com/powershell";
            powerShellUri = "https://mycompany-exchange/powershell";
            // https://ps.outlook.com/Powershell/
            // powerShellUri = "https://mycompany-exchange.mycompany.local";

            System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;

            System.Security.SecureString secpassword = String2SecureString(password);

            System.Management.Automation.PSCredential credential = new System.Management.Automation.PSCredential(userName, secpassword);
            System.Management.Automation.Runspaces.WSManConnectionInfo wSManConnectionInfo = new System.Management.Automation.Runspaces.WSManConnectionInfo(new System.Uri(powerShellUri), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential);
            // wSManConnectionInfo.ComputerName = "mycompany-exchange.mycompany.local";
            wSManConnectionInfo.SkipCACheck = true;
            wSManConnectionInfo.SkipCNCheck = true;
            wSManConnectionInfo.SkipRevocationCheck = true;

            wSManConnectionInfo.OpenTimeout = 30;
            wSManConnectionInfo.OperationTimeout = 30;
            wSManConnectionInfo.CancelTimeout = 30;

            // wSManConnectionInfo.AuthenticationMechanism = System.Management.Automation.Runspaces.AuthenticationMechanism.Default;
            // wSManConnectionInfo.AuthenticationMechanism = System.Management.Automation.Runspaces.AuthenticationMechanism.Negotiate;
            // wSManConnectionInfo.AuthenticationMechanism = System.Management.Automation.Runspaces.AuthenticationMechanism.NegotiateWithImplicitCredential;
            // wSManConnectionInfo.AuthenticationMechanism = System.Management.Automation.Runspaces.AuthenticationMechanism.Basic;
            // wSManConnectionInfo.AuthenticationMechanism = System.Management.Automation.Runspaces.AuthenticationMechanism.Digest;
            wSManConnectionInfo.AuthenticationMechanism = System.Management.Automation.Runspaces.AuthenticationMechanism.Kerberos;

            System.Management.Automation.Runspaces.Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(wSManConnectionInfo);

            runspace.Open();
            // runspace.OpenAsync();
            // await System.Threading.Tasks.Task.Run(() => runspace.Open());

            System.Security.SecureString secureString2 = String2SecureString("Test1234!");

            MailboxType mailboxType = MailboxType.Room;

            using (System.Management.Automation.PowerShell powerShell = System.Management.Automation.PowerShell.Create())
            {
                string name = "Test100";
                string userPrincipalName = "test100@mycompany.com";
                string alias = "Test100";

                powerShell.AddCommand("New-Mailbox");
                powerShell.AddParameter("Password", secureString2);
                powerShell.AddParameter("Name", name);
                powerShell.AddParameter("UserPrincipalName", userPrincipalName);
                powerShell.AddParameter("Alias", alias);

                if (mailboxType != MailboxType.Regular)
                {
                    //powerShell.AddParameter("Room");
                    powerShell.AddParameter(mailboxType.ToString());
                }

                powerShell.Runspace = runspace;
                powerShell.Invoke();
            }

            await System.Threading.Tasks.Task.CompletedTask;
        }

        static void Main(string[] args)
        {
            string cap = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData);
            System.Console.WriteLine(cap);

            CreateMailbox().Wait();

            System.Console.WriteLine("Hello World!");
        }
    }
}