Exemple #1
0
        private void Next()
        {
            using (LogBlock logblock = Log.NotTracing() ? null : new LogBlock(GetType() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name))
            {
                if ((this.ZimbraServerHostName.Length == 0) || (this.ZimbraPort.Length == 0))
                {
                    MessageBox.Show("Please fill in the host name and port", "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                Log.info("ZimbraHostName: " + this.ZimbraServerHostName + "  ZimbraPort: " + this.ZimbraPort);
                Log.info("ZimbraUser: "******"  SSL: " + this.ZimbraSSL);

                try
                {
                    System.Net.IPAddress address = System.Net.IPAddress.Parse(ZimbraServerHostName);
                    MessageBox.Show("Please enter a valid host name rather than an IP address", "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                catch (Exception)
                {
                }

                // ======================================================================
                // Initial server logon
                // ======================================================================
                //Debug.WriteLine("Connecting to server...");
                ZimbraAPI zimbraAPI = new ZimbraAPI(false);
                int       stat      = -1;
                try
                {
                    stat = zimbraAPI.Logon(this.ZimbraServerHostName, this.ZimbraPort, this.ZimbraUser, this.ZimbraUserPasswd, this.ZimbraSSL, false);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "Logon", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                if (stat == 0)
                {
                    string authToken = ZimbraValues.GetZimbraValues().AuthToken;
                    if (authToken.Length > 0)
                    {
                        zimbraAPI.GetInfo();
                        lb.SelectedIndex = 3;
                    }
                }
                else
                {
                    MessageBox.Show(string.Format("Logon Unsuccessful: {0}", zimbraAPI.LastError), "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
        private void Next()
        {
            if ((this.ZimbraServerHostName.Length == 0) || (this.ZimbraPort.Length == 0))
            {
                MessageBox.Show("Please fill in the host name and port", "Zimbra Migration",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            try
            {
                System.Net.IPAddress address = System.Net.IPAddress.Parse(ZimbraServerHostName);
                MessageBox.Show("Please enter a valid host name rather than an IP address",
                                "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            catch (Exception)
            {}
            ZimbraAPI zimbraAPI = new ZimbraAPI(false);

            int stat = -1;

            try
            {
                stat = zimbraAPI.Logon(this.ZimbraServerHostName, this.ZimbraPort, this.ZimbraUser,
                                       this.ZimbraUserPasswd, this.ZimbraSSL, false);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Logon", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (stat == 0)
            {
                string authToken = ZimbraValues.GetZimbraValues().AuthToken;

                if (authToken.Length > 0)
                {
                    zimbraAPI.GetInfo();
                    lb.SelectedIndex = 3;
                }
            }
            else
            {
                MessageBox.Show(string.Format("Logon Unsuccessful: {0}", zimbraAPI.LastError),
                                "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #3
0
        private void Next()
        {
            if ((this.ZimbraServerHostName.Length == 0) || (this.ZimbraPort.Length == 0))
            {
                MessageBox.Show("Please fill in the host name and port", "Zimbra Migration",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            ZimbraAPI zimbraAPI = new ZimbraAPI(true);
            int       stat      = -1;

            try
            {
                stat = zimbraAPI.Logon(this.ZimbraServerHostName, this.ZimbraPort, this.ZimbraAdmin,
                                       this.ZimbraAdminPasswd, this.ZimbraSSL, true);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Logon", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (stat == 0)
            {
                string authToken = ZimbraValues.GetZimbraValues().AuthToken;

                if (authToken.Length > 0)
                {
                    UsersViewModel usersViewModel =
                        ((UsersViewModel)ViewModelPtrs[(int)ViewType.USERS]);
                    ScheduleViewModel scheduleViewModel =
                        ((ScheduleViewModel)ViewModelPtrs[(int)ViewType.SCHED]);
                    string currentDomain = (usersViewModel.DomainList.Count > 0) ?
                                           usersViewModel.DomainList[usersViewModel.CurrentDomainSelection] : "";

                    usersViewModel.DomainList.Clear();
                    scheduleViewModel.CosList.Clear();
                    zimbraAPI.GetAllDomains();
                    for (int i = 0; i < ZimbraValues.GetZimbraValues().Domains.Count; i++)
                    {
                        string s = ZimbraValues.GetZimbraValues().Domains[i];

                        usersViewModel.DomainList.Add(s);
                        // if we've loaded a config file where the domain was specified, then set it as selected
                        if (currentDomain != null)
                        {
                            if (currentDomain.Length > 0)
                            {
                                if (s == currentDomain)
                                {
                                    usersViewModel.CurrentDomainSelection = i;
                                }
                                usersViewModel.DomainsFilledIn = true;
                            }
                        }
                    }
                    zimbraAPI.GetAllCos();
                    foreach (CosInfo cosinfo in ZimbraValues.GetZimbraValues().COSes)
                    {
                        scheduleViewModel.CosList.Add(new CosInfo(cosinfo.CosName, cosinfo.CosID));
                    }
                    lb.SelectedIndex = 3;
                }
            }
            else
            {
                MessageBox.Show(string.Format("Logon Unsuccessful: {0}", zimbraAPI.LastError),
                                "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #4
0
        private void Next()
        {
            if ((this.ZimbraServerHostName.Length == 0) || (this.ZimbraPort.Length == 0))
            {
                MessageBox.Show("Please fill in the host name and port", "Zimbra Migration",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            ZimbraAPI zimbraAPI = new ZimbraAPI(true);
            int       stat      = -1;

            try
            {
                stat = zimbraAPI.Logon(this.ZimbraServerHostName, this.ZimbraPort, this.ZimbraAdmin,
                                       this.ZimbraAdminPasswd, this.ZimbraSSL, true);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Logon", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (stat == 0)
            {
                string authToken = ZimbraValues.GetZimbraValues().AuthToken;

                if (authToken.Length > 0)
                {
                    UsersViewModel usersViewModel =
                        ((UsersViewModel)ViewModelPtrs[(int)ViewType.USERS]);
                    ScheduleViewModel scheduleViewModel =
                        ((ScheduleViewModel)ViewModelPtrs[(int)ViewType.SCHED]);

                    string currentDomain = (usersViewModel.DomainInfoList.Count > 0) ?
                                           usersViewModel.DomainInfoList[usersViewModel.CurrentDomainSelection].DomainName : "";

                    usersViewModel.DomainInfoList.Clear();
                    usersViewModel.DomainList.Clear();
                    scheduleViewModel.CosList.Clear();

                    zimbraAPI.GetAllDomains();

                    foreach (DomainInfo domaininfo in ZimbraValues.GetZimbraValues().ZimbraDomains)
                    {
                        string dName = domaininfo.DomainName;
                        usersViewModel.DomainInfoList.Add(new DomainInfo(domaininfo.DomainName, domaininfo.DomainID, domaininfo.zimbraDomainDefaultCOSId));
                        usersViewModel.DomainList.Add(dName);

                        if (dName == currentDomain)
                        {
                            usersViewModel.CurrentDomainSelection = usersViewModel.DomainInfoList.Count;
                        }
                    }

                    usersViewModel.DomainsFilledIn = true;

                    zimbraAPI.GetAllCos();

                    foreach (CosInfo cosinfo in ZimbraValues.GetZimbraValues().COSes)
                    {
                        scheduleViewModel.CosList.Add(new CosInfo(cosinfo.CosName, cosinfo.CosID));
                    }
                    lb.SelectedIndex = 3;
                }
            }
            else
            {
                MessageBox.Show(string.Format("Logon Unsuccessful: {0}", zimbraAPI.LastError),
                                "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #5
0
        private void Next()
        {
            using (LogBlock logblock = Log.NotTracing() ? null : new LogBlock(GetType() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name))
            {
                if ((this.ZimbraServerHostName.Length == 0) || (this.ZimbraPort.Length == 0))
                {
                    MessageBox.Show("Please fill in the host name and port", "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                Log.info("ZimbraHostName: " + this.ZimbraServerHostName + "  ZimbraPort: " + this.ZimbraPort);
                Log.info("ZimbraAdmin: " + this.ZimbraAdmin + "  SSL: " + this.ZimbraSSL);

                ZimbraAPI zimbraAPI = new ZimbraAPI(true);
                int       stat      = -1;
                try
                {
                    stat = zimbraAPI.Logon(this.ZimbraServerHostName, this.ZimbraPort, this.ZimbraAdmin, this.ZimbraAdminPasswd, this.ZimbraSSL, true);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "Logon", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                if (stat == 0)
                {
                    string authToken = ZimbraValues.GetZimbraValues().AuthToken;
                    if (authToken.Length > 0)
                    {
                        UsersViewModel         usersViewModel         = ((UsersViewModel)ViewModelPtrs[(int)ViewType.USERS]);
                        ScheduleViewModel      scheduleViewModel      = ((ScheduleViewModel)ViewModelPtrs[(int)ViewType.SCHED]);
                        PublicfoldersViewModel publicfoldersViewModel = ((PublicfoldersViewModel)ViewModelPtrs[(int)ViewType.PUBFLDS]);


                        string currentDomain = (usersViewModel.DomainInfoList.Count > 0) ? usersViewModel.DomainInfoList[usersViewModel.CurrentDomainSelection].DomainName : "";
                        currentDomain = (publicfoldersViewModel.DomainInfoList.Count > 0) ? publicfoldersViewModel.DomainInfoList[publicfoldersViewModel.CurrentDomainSelection].DomainName : "";

                        usersViewModel.DomainInfoList.Clear();
                        usersViewModel.DomainList.Clear();
                        publicfoldersViewModel.DomainInfoList.Clear();
                        publicfoldersViewModel.DomainList.Clear();
                        scheduleViewModel.CosList.Clear();

                        // ----------------------------------------------
                        // Get domains
                        // ----------------------------------------------
                        zimbraAPI.GetAllDomains();
                        foreach (DomainInfo domaininfo in ZimbraValues.GetZimbraValues().ZimbraDomains)
                        {
                            string dName = domaininfo.DomainName;
                            usersViewModel.DomainInfoList.Add(new DomainInfo(domaininfo.DomainName, domaininfo.DomainID, domaininfo.zimbraDomainDefaultCOSId));
                            usersViewModel.DomainList.Add(dName);

                            publicfoldersViewModel.DomainInfoList.Add(new DomainInfo(domaininfo.DomainName, domaininfo.DomainID, domaininfo.zimbraDomainDefaultCOSId));
                            publicfoldersViewModel.DomainList.Add(dName);

                            if (dName == currentDomain)
                            {
                                usersViewModel.CurrentDomainSelection         = usersViewModel.DomainInfoList.Count;
                                publicfoldersViewModel.CurrentDomainSelection = publicfoldersViewModel.DomainInfoList.Count;
                            }
                        }

                        usersViewModel.DomainsFilledIn         = true;
                        publicfoldersViewModel.DomainsFilledIn = true;

                        // ----------------------------------------------
                        // Get COS
                        // ----------------------------------------------
                        zimbraAPI.GetAllCos();
                        foreach (CosInfo cosinfo in ZimbraValues.GetZimbraValues().COSes)
                        {
                            scheduleViewModel.CosList.Add(new CosInfo(cosinfo.CosName, cosinfo.CosID));
                        }
                        lb.SelectedIndex = 3;
                    }
                }
                else
                {
                    MessageBox.Show(string.Format("Logon Unsuccessful: {0}", zimbraAPI.LastError), "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Exemple #6
0
        public void DesktopLoad()
        {
            using (LogBlock logblock = Log.NotTracing() ? null : new LogBlock(GetType() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name))
            {
                string appDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                string filePath      = Path.Combine(appDataFolder, "Zimbra\\Zimbra Desktop\\conf\\localconfig.xml");

                if (File.Exists(filePath))
                {
                    try
                    {
                        XmlDocument xml = new XmlDocument();
                        xml.Load(filePath);  // suppose that str string contains "<Names>...</Names>"

                        XmlNodeList xnList = xml.SelectNodes("//localconfig/key[@name='zdesktop_installation_key']");
                        string      pwd    = "";
                        foreach (XmlNode xn in xnList)
                        {
                            pwd = xn.InnerText;
                        }

                        xnList = xml.SelectNodes("//localconfig/key[@name='zimbra_admin_service_port']");
                        string port = "";
                        foreach (XmlNode xn in xnList)
                        {
                            port = xn.InnerText;
                        }


                        ZimbraServerHostName = "localhost";
                        ZimbraPort           = port;
                        ZimbraUser           = "******";
                        ZimbraUserPasswd     = pwd;
                        ZimbraSSL            = false;

                        if ((this.ZimbraServerHostName.Length == 0) || (this.ZimbraPort.Length == 0))
                        {
                            MessageBox.Show("Please fill in the host name and port", "Zimbra Migration",
                                            MessageBoxButton.OK, MessageBoxImage.Error);
                            return;
                        }
                        try
                        {
                            System.Net.IPAddress address = System.Net.IPAddress.Parse(ZimbraServerHostName);
                            MessageBox.Show("Please enter a valid host name rather than an IP address",
                                            "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                            return;
                        }
                        catch (Exception)
                        {
                        }


                        ZimbraAPI zimbraAPI = new ZimbraAPI(false);
                        int       stat      = -1;
                        try
                        {
                            stat = zimbraAPI.Logon(this.ZimbraServerHostName, this.ZimbraPort, this.ZimbraUser, this.ZimbraUserPasswd, this.ZimbraSSL, false);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message, "Logon", MessageBoxButton.OK, MessageBoxImage.Error);
                            return;
                        }

                        if (stat == 0)
                        {
                            string authToken = ZimbraValues.GetZimbraValues().AuthToken;
                            if (authToken.Length > 0)
                            {
                                zimbraAPI.GetInfo();
                                lb.SelectedIndex = 3;
                            }
                        }
                        else
                        {
                            MessageBox.Show(string.Format("Logon Unsuccessful: {0}", zimbraAPI.LastError), "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                    catch (Exception e)
                    {
                        string temp = string.Format("Incorrect configuration file format.\n{0}", e.Message);
                        MessageBox.Show(temp, "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                        //fileRead.Close();
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("Please Install Zimbra Desktop before executing migration ", "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                    lb.SelectedIndex = 1;
                    throw new Exception("Can't find Zimbra Desktop installation");
                }
            }
        }