コード例 #1
0
        private static int RunAdamSchemaImport(string instanceName, string schemaFilePath, string macroName, string macroValue, string tempDir)
        {
            int    ldapPort = AdamServiceSettings.GetFromRegistry(instanceName).LdapPort;
            string schemaImportProcessArguments = ManageAdamService.GetSchemaImportProcessArguments(schemaFilePath, ldapPort, tempDir, macroName, macroValue);

            return(Utils.LogRunProcess("ldifde.exe", schemaImportProcessArguments, ManageAdamService.GetAdamToolsDir()));
        }
コード例 #2
0
 private static void InstallAdamInstance(string answerFileName, AdamServiceSettings adamServiceSettings, WriteVerboseDelegate writeVerbose)
 {
     TaskLogger.LogEnter();
     ManageAdamService.RunAdamInstall(answerFileName);
     ManageAdamService.SetAdamServiceArgs(adamServiceSettings.InstanceName, writeVerbose);
     ManageAdamService.SetAcls(adamServiceSettings);
     TaskLogger.LogExit();
 }
コード例 #3
0
        public static bool GetSettingsExist(string instanceName)
        {
            bool result;

            using (RegistryKey registryKey = AdamServiceSettings.GetAdamServiceSubKey(instanceName).Open())
            {
                result = (null != registryKey);
            }
            return(result);
        }
コード例 #4
0
        private static void RunDsAcls(AdamServiceSettings adamServiceSettings, string subTreeDn)
        {
            string arguments = string.Format("\"\\\\localhost:{0}\\{1}\" /I:T /G \"NT AUTHORITY\\SYSTEM\":GR;; \"NT AUTHORITY\\NETWORKSERVICE\":GR;; \"{2}\":GA;;", adamServiceSettings.LdapPort, subTreeDn, ManageAdamService.BuiltinAdminSid);
            int    num       = Utils.LogRunProcess("dsacls.exe", arguments, ManageAdamService.GetAdamToolsDir());

            if (num != 0)
            {
                throw new AdamSetAclsProcessFailureException("dsacls.exe", num, subTreeDn);
            }
        }
コード例 #5
0
        private static void SetAdministrator(AdamServiceSettings adamServiceSettings, string configContainerDn)
        {
            string path  = string.Format("{0}:{1}/CN=Administrators,CN=Roles,{2}", "LDAP://localhost", adamServiceSettings.LdapPort, configContainerDn);
            string value = string.Format("<SID={0}>", ManageAdamService.BuiltinAdminSid);

            using (DirectoryEntry directoryEntry = new DirectoryEntry(path))
            {
                directoryEntry.Properties["member"].Add(value);
                directoryEntry.CommitChanges();
            }
        }
コード例 #6
0
 private static void SetAcls(AdamServiceSettings adamServiceSettings)
 {
     ManageAdamService.RunDsAcls(adamServiceSettings, "OU=MSExchangeGateway");
     using (DirectoryEntry rootDirectoryEntry = AdsUtils.GetRootDirectoryEntry(adamServiceSettings.LdapPort))
     {
         string text = (string)rootDirectoryEntry.Properties["ConfigurationNamingContext"].Value;
         ManageAdamService.RunDsAcls(adamServiceSettings, text);
         string subTreeDn = "CN=Deleted Objects," + text;
         ManageAdamService.RunDsAcls(adamServiceSettings, subTreeDn);
         ManageAdamService.SetAdministrator(adamServiceSettings, text);
     }
 }
コード例 #7
0
 protected override void InternalValidate()
 {
     base.InternalValidate();
     if (!AdamServiceSettings.GetSettingsExist(this.InstanceName))
     {
         base.WriteError(new InvalidAdamInstanceNameException(this.InstanceName), ErrorCategory.InvalidArgument, null);
     }
     if (!File.Exists(this.LdapFileName))
     {
         base.WriteError(new InvalidLdapFileNameException(), ErrorCategory.InvalidArgument, null);
     }
 }
コード例 #8
0
        public static void DeleteFromRegistry(string instanceName)
        {
            RegistrySubKey adamServiceSubKey = AdamServiceSettings.GetAdamServiceSubKey(instanceName);

            adamServiceSubKey.DeleteTreeIfExist();
            using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\ExchangeServer\\v15\\EdgeTransportRole\\AdamSettings"))
            {
                if (registryKey != null && registryKey.SubKeyCount == 0)
                {
                    Registry.LocalMachine.DeleteSubKey("SOFTWARE\\Microsoft\\ExchangeServer\\v15\\EdgeTransportRole\\AdamSettings");
                }
            }
        }
コード例 #9
0
        public void SaveToRegistry()
        {
            RegistrySubKey adamServiceSubKey = AdamServiceSettings.GetAdamServiceSubKey(this.InstanceName);

            adamServiceSubKey.DeleteTreeIfExist();
            using (RegistryKey registryKey = adamServiceSubKey.Create())
            {
                registryKey.SetValue("DataFilesPath", this.DataFilesPath);
                registryKey.SetValue("LogFilesPath", this.LogFilesPath);
                registryKey.SetValue("LdapPort", this.LdapPort);
                registryKey.SetValue("SslPort", this.SslPort);
            }
        }
コード例 #10
0
        public static AdamServiceSettings GetFromRegistry(string instanceName)
        {
            AdamServiceSettings result;

            using (RegistryKey registryKey = AdamServiceSettings.GetAdamServiceSubKey(instanceName).Open())
            {
                string text  = registryKey.GetValue("DataFilesPath") as string;
                string text2 = registryKey.GetValue("LogFilesPath") as string;
                int    num   = (int)registryKey.GetValue("LdapPort");
                int    num2  = (int)registryKey.GetValue("SslPort");
                result = new AdamServiceSettings(instanceName, text, text2, num, num2);
            }
            return(result);
        }
コード例 #11
0
        public static void InstallAdam(string instanceName, string dataPath, string logPath, int port, int sslPort, WriteVerboseDelegate writeVerbose)
        {
            Utils.CreateDirectory(dataPath, "DataFilesPath");
            Utils.CreateDirectory(logPath, "LogFilesPath");
            AdamServiceSettings.DeleteFromRegistry(instanceName);
            AdamServiceSettings adamServiceSettings = new AdamServiceSettings(instanceName, Path.Combine(dataPath, "Adam"), Path.Combine(logPath, "Adam"), port, sslPort);

            using (TempFileCollection tempFileCollection = new TempFileCollection())
            {
                string answerFileName = ManageAdamService.MakeAnswerFile(tempFileCollection, adamServiceSettings);
                ManageAdamService.InstallAdamInstance(answerFileName, adamServiceSettings, writeVerbose);
                adamServiceSettings.SaveToRegistry();
            }
        }
コード例 #12
0
        private static string MakeAnswerFile(TempFileCollection tempFiles, AdamServiceSettings adamServiceSettings)
        {
            string text = tempFiles.AddExtension("ini");
            string path = Path.Combine(ConfigurationContext.Setup.SetupDataPath, "AdamInstallAnswer.ini");

            using (StreamReader streamReader = File.OpenText(path))
            {
                using (StreamWriter streamWriter = File.CreateText(text))
                {
                    string text2;
                    while ((text2 = streamReader.ReadLine()) != null)
                    {
                        if (!string.IsNullOrEmpty(text2) && text2[0] != ';')
                        {
                            if (text2.StartsWith("InstanceName"))
                            {
                                text2 = Utils.MakeIniFileSetting("InstanceName", adamServiceSettings.InstanceName);
                            }
                            else if (text2.StartsWith("DataFilesPath"))
                            {
                                text2 = Utils.MakeIniFileSetting("DataFilesPath", adamServiceSettings.DataFilesPath);
                            }
                            else if (text2.StartsWith("LogFilesPath"))
                            {
                                text2 = Utils.MakeIniFileSetting("LogFilesPath", adamServiceSettings.LogFilesPath);
                            }
                            else if (text2.StartsWith("LocalLDAPPortToListenOn"))
                            {
                                text2 = Utils.MakeIniFileSetting("LocalLDAPPortToListenOn", adamServiceSettings.LdapPort.ToString());
                            }
                            else if (text2.StartsWith("LocalSSLPortToListenOn"))
                            {
                                text2 = Utils.MakeIniFileSetting("LocalSSLPortToListenOn", adamServiceSettings.SslPort.ToString());
                            }
                            else if (text2.StartsWith("NewApplicationPartitionToCreate"))
                            {
                                text2 = Utils.MakeIniFileSetting("NewApplicationPartitionToCreate", "OU=MSExchangeGateway");
                            }
                            streamWriter.WriteLine(text2);
                            TaskLogger.Log(new LocalizedString("Answer File:" + text2));
                        }
                    }
                    streamWriter.Flush();
                }
            }
            return(text);
        }
コード例 #13
0
 public static void UninstallAdam(string instanceName)
 {
     ManageAdamService.RunAdamUninstall(instanceName);
     AdamServiceSettings.DeleteFromRegistry(instanceName);
 }