public void DeleteServerTlb(string progId, string classId, string interfaceId, string srcTlbPath, string rootWebServer, string baseUrl, string virtualRoot, string operation, string assemblyName, string typeName)
        {
            try
            {
                new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
            }
            catch (SecurityException)
            {
                ComSoapPublishError.Report(Resource.FormatString("Soap_SecurityFailure"));
                throw;
            }
            string name = assemblyName;

            if ((((progId.Length > 0) || (classId.Length > 0)) || ((assemblyName.Length > 0) || (typeName.Length > 0))) && ((baseUrl.Length > 0) || (virtualRoot.Length > 0)))
            {
                string str3 = SoapServerInfo.ServerPhysicalPath(rootWebServer, baseUrl, virtualRoot, false);
                string str4 = srcTlbPath.ToLower(CultureInfo.InvariantCulture);
                if (!str4.EndsWith("scrobj.dll", StringComparison.Ordinal))
                {
                    if (str4.EndsWith("mscoree.dll", StringComparison.Ordinal))
                    {
                        Type typeFromProgID = Type.GetTypeFromProgID(progId);
                        typeName = typeFromProgID.FullName;
                        name     = typeFromProgID.Assembly.GetName().Name;
                    }
                    else
                    {
                        name = new GenerateMetadata().GetAssemblyName(srcTlbPath, str3 + @"\bin\");
                        if (name.Length > 0)
                        {
                            try
                            {
                                typeName = this.GetTypeName(str3 + @"\bin\" + name + ".dll", progId, classId);
                            }
                            catch (DirectoryNotFoundException)
                            {
                            }
                            catch (FileNotFoundException)
                            {
                            }
                        }
                    }
                    if ((!string.IsNullOrEmpty(progId) && !string.IsNullOrEmpty(name)) && !string.IsNullOrEmpty(typeName))
                    {
                        DiscoFile file         = new DiscoFile();
                        string    assemblyFile = str3 + @"\bin\" + name + ".dll";
                        SoapServerConfig.DeleteComponent(str3 + @"\Web.Config", name, typeName, progId, assemblyFile);
                        file.DeleteElement(str3 + @"\Default.disco", progId + ".soap?WSDL");
                    }
                }
            }
        }
        public void CreateVirtualRootEx(string rootWebServer, string inBaseUrl, string inVirtualRoot, string homePage, string discoFile, string secureSockets, string authentication, string operation, out string baseUrl, out string virtualRoot, out string physicalPath)
        {
            baseUrl      = "";
            virtualRoot  = "";
            physicalPath = "";
            bool inDefault   = true;
            bool windowsAuth = true;
            bool anonymous   = false;
            bool flag4       = false;
            bool flag5       = false;
            bool impersonate = true;

            try
            {
                new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
                if ((inBaseUrl.Length > 0) || (inVirtualRoot.Length > 0))
                {
                    string str = "IIS://localhost/W3SVC/1/ROOT";
                    if (rootWebServer.Length > 0)
                    {
                        str = rootWebServer;
                    }
                    if (authentication.ToLower(CultureInfo.InvariantCulture) == "anonymous")
                    {
                        anonymous   = true;
                        windowsAuth = false;
                        impersonate = false;
                    }
                    flag4     = SoapServerInfo.BoolFromString(discoFile, flag4);
                    flag5     = SoapServerInfo.BoolFromString(homePage, flag5);
                    inDefault = SoapServerInfo.BoolFromString(secureSockets, inDefault);
                    string inProtocol = "https";
                    if (!inDefault)
                    {
                        inProtocol = "http";
                    }
                    SoapServerInfo.CheckUrl(inBaseUrl, inVirtualRoot, inProtocol);
                    SoapServerInfo.ParseUrl(inBaseUrl, inVirtualRoot, inProtocol, out baseUrl, out virtualRoot);
                    physicalPath = SoapServerInfo.ServerPhysicalPath(str, inBaseUrl, inVirtualRoot, true);
                    SoapServerConfig.Create(physicalPath, impersonate, windowsAuth);
                    if (flag4)
                    {
                        new DiscoFile().Create(physicalPath, "Default.disco");
                    }
                    else if (File.Exists(physicalPath + @"\Default.disco"))
                    {
                        File.Delete(physicalPath + @"\Default.disco");
                    }
                    if (flag5)
                    {
                        HomePage page     = new HomePage();
                        string   discoRef = "";
                        if (flag4)
                        {
                            discoRef = "Default.disco";
                        }
                        page.Create(physicalPath, virtualRoot, "Default.aspx", discoRef);
                    }
                    else if (File.Exists(physicalPath + @"\Default.aspx"))
                    {
                        File.Delete(physicalPath + @"\Default.aspx");
                    }
                    IISVirtualRootEx.CreateOrModify(str, physicalPath, virtualRoot, inDefault, windowsAuth, anonymous, flag5);
                }
            }
            catch (Exception exception)
            {
                if ((exception is NullReferenceException) || (exception is SEHException))
                {
                    throw;
                }
                ComSoapPublishError.Report(Resource.FormatString("Soap_VRootCreationFailed") + " " + virtualRoot);
                throw;
            }
        }
Exemplo n.º 3
0
        /// <include file='doc\SoapServerVroot.uex' path='docs/doc[@for="SoapServerVRoot.CreateVirtualRootEx"]/*' />
        public void CreateVirtualRootEx(
            string rootWebServer,
            string inBaseUrl,
            string inVirtualRoot,
            string homePage,
            string discoFile,
            string secureSockets,
            string authentication,
            string operation,
            out string baseUrl,
            out string virtualRoot,
            out string physicalPath
            )
        {
            // if Operation if an empty string, the VRoot will be published
            baseUrl      = "";
            virtualRoot  = "";
            physicalPath = "";
            bool bSSL         = true;
            bool bWindowsAuth = true;
            bool bAnonymous   = false;
            bool bDiscoFile   = false;
            bool bHomePage    = false;
            bool bImpersonate = true;

            try
            {
                SecurityPermission sp = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
                sp.Demand();
                Platform.Assert(Platform.Whistler, "SoapServerVRoot.CreateVirtualRootEx");
                if (inBaseUrl.Length <= 0 && inVirtualRoot.Length <= 0)
                {
                    return;
                }
                string rootWeb = "IIS://localhost/W3SVC/1/ROOT";
                if (rootWebServer.Length > 0)
                {
                    rootWeb = rootWebServer;
                }
                if (authentication.ToLower(CultureInfo.InvariantCulture) == "anonymous")
                {
                    bAnonymous   = true;
                    bWindowsAuth = false;
                    bImpersonate = false;
                }
                bDiscoFile = SoapServerInfo.BoolFromString(discoFile, bDiscoFile);
                bHomePage  = SoapServerInfo.BoolFromString(homePage, bHomePage);
                bSSL       = SoapServerInfo.BoolFromString(secureSockets, bSSL);
                string protocol = "https";
                if (!bSSL)
                {
                    protocol = "http";
                }
                SoapServerInfo.ParseUrl(inBaseUrl, inVirtualRoot, protocol, out baseUrl, out virtualRoot);
                physicalPath = SoapServerInfo.ServerPhysicalPath(rootWeb, inBaseUrl, inVirtualRoot, true);
                SoapServerConfig.Create(physicalPath, bImpersonate, bWindowsAuth);
                if (bDiscoFile)
                {
                    DiscoFile webDisco = new DiscoFile();
                    webDisco.Create(physicalPath, "Default.disco");
                }
                else
                {
                    if (File.Exists(physicalPath + "\\Default.disco"))
                    {
                        File.Delete(physicalPath + "\\Default.disco");
                    }
                }
                if (bHomePage)
                {
                    HomePage webPage       = new HomePage();
                    string   discoFileName = "";
                    if (bDiscoFile)
                    {
                        discoFileName = "Default.disco";
                    }
                    webPage.Create(physicalPath, virtualRoot, "Default.aspx", discoFileName);
                }
                else
                {
                    if (File.Exists(physicalPath + "\\Default.aspx"))
                    {
                        File.Delete(physicalPath + "\\Default.aspx");
                    }
                }
                IISVirtualRootEx.CreateOrModify(rootWeb, physicalPath, virtualRoot, bSSL, bWindowsAuth, bAnonymous, bHomePage);
            }
            catch
            {
                string etxt = Resource.FormatString("Soap_VRootCreationFailed");
                ComSoapPublishError.Report(etxt + " " + virtualRoot);
                throw;
            }
        }
        public void AddServerTlb(string progId, string classId, string interfaceId, string srcTlbPath, string rootWebServer, string inBaseUrl, string inVirtualRoot, string clientActivated, string wellKnown, string discoFile, string operation, out string strAssemblyName, out string typeName)
        {
            string name = string.Empty;

            strAssemblyName = string.Empty;
            typeName        = string.Empty;
            bool flag      = false;
            bool inDefault = false;
            bool flag3     = false;
            bool flag4     = true;

            try
            {
                try
                {
                    new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
                }
                catch (SecurityException)
                {
                    ComSoapPublishError.Report(Resource.FormatString("Soap_SecurityFailure"));
                    throw;
                }
                if ((operation != null) && (operation.ToLower(CultureInfo.InvariantCulture) == "delete"))
                {
                    flag = true;
                }
                if (srcTlbPath.Length > 0)
                {
                    inDefault = SoapServerInfo.BoolFromString(discoFile, inDefault);
                    flag3     = SoapServerInfo.BoolFromString(wellKnown, flag3);
                    flag4     = SoapServerInfo.BoolFromString(clientActivated, flag4);
                    string str3 = SoapServerInfo.ServerPhysicalPath(rootWebServer, inBaseUrl, inVirtualRoot, !flag);
                    string str4 = srcTlbPath.ToLower(CultureInfo.InvariantCulture);
                    if (str4.EndsWith("mscoree.dll", StringComparison.Ordinal))
                    {
                        Type typeFromProgID = Type.GetTypeFromProgID(progId);
                        typeName = typeFromProgID.FullName;
                        name     = typeFromProgID.Assembly.GetName().Name;
                    }
                    else if (str4.EndsWith("scrobj.dll", StringComparison.Ordinal))
                    {
                        if (!flag)
                        {
                            throw new ServicedComponentException(Resource.FormatString("ServicedComponentException_WSCNotSupported"));
                        }
                    }
                    else
                    {
                        string           error    = "";
                        GenerateMetadata metadata = new GenerateMetadata();
                        if (flag)
                        {
                            name = metadata.GetAssemblyName(srcTlbPath, str3 + @"\bin\");
                        }
                        else
                        {
                            name = metadata.GenerateSigned(srcTlbPath, str3 + @"\bin\", false, out error);
                        }
                        if (!string.IsNullOrEmpty(name))
                        {
                            try
                            {
                                typeName = this.GetTypeName(str3 + @"\bin\" + name + ".dll", progId, classId);
                            }
                            catch (DirectoryNotFoundException)
                            {
                                if (!flag)
                                {
                                    throw;
                                }
                            }
                            catch (FileNotFoundException)
                            {
                                if (!flag)
                                {
                                    throw;
                                }
                            }
                        }
                    }
                    if ((!string.IsNullOrEmpty(progId) && !string.IsNullOrEmpty(name)) && !string.IsNullOrEmpty(typeName))
                    {
                        DiscoFile file         = new DiscoFile();
                        string    assemblyFile = str3 + @"\bin\" + name + ".dll";
                        if (flag)
                        {
                            SoapServerConfig.DeleteComponent(str3 + @"\Web.Config", name, typeName, progId, assemblyFile);
                            file.DeleteElement(str3 + @"\Default.disco", progId + ".soap?WSDL");
                        }
                        else
                        {
                            SoapServerConfig.AddComponent(str3 + @"\Web.Config", name, typeName, progId, assemblyFile, "SingleCall", flag3, flag4);
                            if (inDefault)
                            {
                                file.AddElement(str3 + @"\Default.disco", progId + ".soap?WSDL");
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(name))
                    {
                        string fileName = str3 + @"bin\" + name + ".dll";
                        strAssemblyName = new AssemblyManager().GetFullName(fileName);
                    }
                }
            }
            catch (ServicedComponentException exception)
            {
                this.ThrowHelper("Soap_PublishServerTlbFailure", exception);
            }
            catch (RegistrationException exception2)
            {
                this.ThrowHelper("Soap_PublishServerTlbFailure", exception2);
            }
            catch (Exception exception3)
            {
                if ((exception3 is NullReferenceException) || (exception3 is SEHException))
                {
                    throw;
                }
                this.ThrowHelper("Soap_PublishServerTlbFailure", null);
            }
        }
Exemplo n.º 5
0
        /// <include file='doc\SoapServerTlb.uex' path='docs/doc[@for="SoapServerTlb.AddServerTlb"]/*' />
        public void AddServerTlb(
            string progId,
            string classId,
            string interfaceId,
            string srcTlbPath,
            string rootWebServer,
            string inBaseUrl,
            string inVirtualRoot,
            string clientActivated,
            string wellKnown,
            string discoFile,
            string operation,
            out string strAssemblyName,
            out string typeName
            )
        {
            strAssemblyName = "";
            typeName        = "";
            bool bDelete = false;
            //these are the defaults for these flags
            bool bDiscoFile       = false;
            bool bWellKnown       = false;
            bool bClientActivated = true;

            try
            {
                try
                {
                    SecurityPermission sp = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
                    sp.Demand();
                }
                catch (Exception e)
                {
                    if (e.GetType() == typeof(System.Security.SecurityException))
                    {
                        string Error = Resource.FormatString("Soap_SecurityFailure");
                        ComSoapPublishError.Report(Error);
                    }
                    throw;
                }
                Platform.Assert(Platform.Whistler, "SoapServerTlb.AddServerTlb");

                if (null != operation && operation.ToLower(CultureInfo.InvariantCulture) == "delete")
                {
                    bDelete = true;
                }
                //if ProgId is an empty string, it means it does not go in the configuration file
                if (srcTlbPath.Length <= 0)
                {
                    return;
                }
                bDiscoFile       = SoapServerInfo.BoolFromString(discoFile, bDiscoFile);
                bWellKnown       = SoapServerInfo.BoolFromString(wellKnown, bWellKnown);
                bClientActivated = SoapServerInfo.BoolFromString(clientActivated, bClientActivated);
                string PhysicalPath = SoapServerInfo.ServerPhysicalPath(rootWebServer, inBaseUrl, inVirtualRoot, !bDelete);
                string srcdll       = srcTlbPath.ToLower(CultureInfo.InvariantCulture);
                if (srcdll.EndsWith("mscoree.dll"))
                {
                    Type typ = Type.GetTypeFromProgID(progId);
                    typeName = typ.FullName;
                    Assembly     assem     = typ.Assembly;
                    AssemblyName assemname = assem.GetName();
                    strAssemblyName = assemname.Name;
                }
                else if (srcdll.EndsWith("scrobj.dll"))
                {
                    if (!bDelete)
                    {
                        throw new ServicedComponentException(Resource.FormatString("ServicedComponentException_WSCNotSupported"));
                    }
                }
                else
                {
                    string           Error   = "";
                    GenerateMetadata metaGen = new GenerateMetadata();
                    if (bDelete)
                    {
                        strAssemblyName = metaGen.GetAssemblyName(srcTlbPath, PhysicalPath + "\\bin\\");
                    }
                    else
                    {
                        strAssemblyName = metaGen.GenerateSigned(srcTlbPath, PhysicalPath + "\\bin\\", false, out Error);
                    }
                    if (strAssemblyName.Length > 0)
                    {
                        try
                        {
                            //TODO - review GetTypeNameFromProgId to determine if we can use the IID
                            // to simplify the logic
                            typeName = GetTypeName(PhysicalPath + "\\bin\\" + strAssemblyName + ".dll", progId, classId);
                        }
                        catch (Exception e)
                        {
                            if (bDelete && e.GetType() != typeof(System.IO.DirectoryNotFoundException) &&
                                e.GetType() != typeof(System.IO.FileNotFoundException))
                            {
                                throw;
                            }
                        }
                    }
                }
                // pull the generated Assembly.Type from the assembly for configuration files
                if (progId.Length > 0 && strAssemblyName.Length > 0 && typeName.Length > 0)
                {
                    // write to the server configuration files
                    DiscoFile objDiscoFile = new DiscoFile();
                    string    strFileName  = PhysicalPath + "\\bin\\" + strAssemblyName + ".dll";
                    if (bDelete)
                    {
                        SoapServerConfig.DeleteComponent(PhysicalPath + "\\Web.Config", strAssemblyName, typeName, progId, strFileName);
                        objDiscoFile.DeleteElement(PhysicalPath + "\\Default.disco", progId + ".soap?WSDL");
                        // we have no way of telling from a single component what other components are in this type library
                        // metadata assembly.  If we remove from GAC or delete we kill all the other components simultaneously
                        //GacRemove(strFileName);
                        //File.Delete(strFileName);
                    }
                    else
                    {
                        SoapServerConfig.AddComponent(PhysicalPath + "\\Web.Config", strAssemblyName, typeName, progId, strFileName, "SingleCall", bWellKnown, bClientActivated);
                        if (bDiscoFile)
                        {
                            objDiscoFile.AddElement(PhysicalPath + "\\Default.disco", progId + ".soap?WSDL");
                        }
                    }
                }
            }
            catch (Exception e)
            {
                string Error = Resource.FormatString("Soap_PublishServerTlbFailure");
                ComSoapPublishError.Report(Error);
                if (typeof(ServicedComponentException) == e.GetType() || typeof(RegistrationException) == e.GetType())
                {
                    throw;
                }
            }
        }
Exemplo n.º 6
0
        /// <include file='doc\SoapServerTlb.uex' path='docs/doc[@for="SoapServerTlb.DeleteServerTlb"]/*' />
        public void DeleteServerTlb(
            string progId,
            string classId,
            string interfaceId,
            string srcTlbPath,
            string rootWebServer,
            string baseUrl,
            string virtualRoot,
            string operation,
            string assemblyName,
            string typeName
            )
        {
            try
            {
                SecurityPermission sp = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
                sp.Demand();
            }
            catch (Exception e)
            {
                if (e.GetType() == typeof(System.Security.SecurityException))
                {
                    string Error = Resource.FormatString("Soap_SecurityFailure");
                    ComSoapPublishError.Report(Error);
                }
                throw;
            }
            Platform.Assert(Platform.Whistler, "SoapServerTlb.DeleteServerTlb");

            string strAssemblyName = assemblyName;

            if (progId.Length <= 0 && classId.Length <= 0 && assemblyName.Length <= 0 && typeName.Length <= 0)
            {
                return;
            }
            if (baseUrl.Length <= 0 && virtualRoot.Length <= 0)
            {
                return;
            }
            string PhysicalPath = SoapServerInfo.ServerPhysicalPath(rootWebServer, baseUrl, virtualRoot, false);
            string srcdll       = srcTlbPath.ToLower(CultureInfo.InvariantCulture);

            if (srcdll.EndsWith("scrobj.dll"))
            {
                return;                                  //not supported, nothing to do
            }
            if (srcdll.EndsWith("mscoree.dll"))
            {
                Type typ = Type.GetTypeFromProgID(progId);
                typeName = typ.FullName;
                Assembly     assem     = typ.Assembly;
                AssemblyName assemname = assem.GetName();
                strAssemblyName = assemname.Name;
            }
            else
            {
                GenerateMetadata metaGen = new GenerateMetadata();
                strAssemblyName = metaGen.GetAssemblyName(srcTlbPath, PhysicalPath + "\\bin\\");
                if (strAssemblyName.Length > 0)
                {
                    try
                    {
                        //TODO - review GetTypeNameFromProgId to determine if we can use the IID
                        // to simplify the logic
                        typeName = GetTypeName(PhysicalPath + "\\bin\\" + strAssemblyName + ".dll", progId, classId);
                    }
                    catch (Exception e)
                    {
                        if (e.GetType() != typeof(System.IO.DirectoryNotFoundException) &&
                            e.GetType() != typeof(System.IO.FileNotFoundException))
                        {
                            throw;
                        }
                    }
                }
            }
            // pull the generated Assembly.Type from the assembly for configuration files
            if (progId.Length > 0 && strAssemblyName.Length > 0 && typeName.Length > 0)
            {
                // write to the server configuration files
                DiscoFile discoFile   = new DiscoFile();
                string    strFileName = PhysicalPath + "\\bin\\" + strAssemblyName + ".dll";
                SoapServerConfig.DeleteComponent(PhysicalPath + "\\Web.Config", strAssemblyName, typeName, progId, strFileName);
                discoFile.DeleteElement(PhysicalPath + "\\Default.disco", progId + ".soap?WSDL");
                // we have no way of telling from a single component what other components are in this type library
                // metadata assembly.  If we remove from GAC or delete we kill all the other components simultaneously
                //GacRemove(strFileName);
                //File.Delete(strFileName);
            }
        }