예제 #1
0
        private static unsafe void ReserveURL(string networkURL, string securityDescriptor)
        {
            uint retVal = ErrorCodes.NOERROR;

            retVal = HttpApiNative.HttpInitialize(HttpApiConstants.HTTPAPI_VERSION_2, HttpApiConstants.HTTP_INITIALIZE_CONFIG, IntPtr.Zero);
            if (ErrorCodes.NOERROR == retVal)
            {
                try
                {
                    HTTP_SERVICE_CONFIG_URLACL_KEY keyDesc = new HTTP_SERVICE_CONFIG_URLACL_KEY(networkURL);
                    HTTP_SERVICE_CONFIG_URLACL_PARAM paramDesc = new HTTP_SERVICE_CONFIG_URLACL_PARAM(securityDescriptor);

                    HTTP_SERVICE_CONFIG_URLACL_SET inputConfigInfoSet = new HTTP_SERVICE_CONFIG_URLACL_SET();
                    inputConfigInfoSet.KeyDesc = keyDesc;
                    inputConfigInfoSet.ParamDesc = paramDesc;

                    retVal = HttpApiNative.HttpSetServiceConfiguration(IntPtr.Zero,
                        HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
                        ref inputConfigInfoSet,
                        Marshal.SizeOf(inputConfigInfoSet),
                        IntPtr.Zero);
                }
                finally
                {
                    HttpApiNative.HttpTerminate(HttpApiConstants.HTTP_INITIALIZE_CONFIG, IntPtr.Zero);
                }
            }

            if (ErrorCodes.ERROR_ALREADY_EXISTS == retVal)
            {
                throw new ArgumentException("A reservation for this URL already exists.");
            }
            else if (ErrorCodes.NOERROR != retVal)
            {
                throw new Win32Exception((int)retVal);
            }
        }
예제 #2
0
 public static extern uint HttpSetServiceConfiguration(
         IntPtr ServiceIntPtr,
         HTTP_SERVICE_CONFIG_ID ConfigId,
         ref HTTP_SERVICE_CONFIG_URLACL_SET pConfigInformation,
         int ConfigInformationLength,
         IntPtr pOverlapped);
예제 #3
0
        private static void FreeURL(string networkURL, string securityDescriptor)
        {
            uint retVal = (uint)ErrorCodes.NOERROR;

            retVal = HttpApiNative.HttpInitialize(HttpApiConstants.HTTPAPI_VERSION_2, HttpApiConstants.HTTP_INITIALIZE_CONFIG, IntPtr.Zero);
            if ((uint)ErrorCodes.NOERROR == retVal)
            {
                HTTP_SERVICE_CONFIG_URLACL_KEY urlAclKey = new HTTP_SERVICE_CONFIG_URLACL_KEY(networkURL);
                HTTP_SERVICE_CONFIG_URLACL_PARAM urlAclParam = new HTTP_SERVICE_CONFIG_URLACL_PARAM(securityDescriptor);

                HTTP_SERVICE_CONFIG_URLACL_SET urlAclSet = new HTTP_SERVICE_CONFIG_URLACL_SET();
                urlAclSet.KeyDesc = urlAclKey;
                urlAclSet.ParamDesc = urlAclParam;

                int configInformationSize = Marshal.SizeOf(urlAclSet);

                retVal = HttpApiNative.HttpDeleteServiceConfiguration(IntPtr.Zero,
                    HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
                    ref urlAclSet,
                    configInformationSize,
                    IntPtr.Zero);

                HttpApiNative.HttpTerminate(HttpApiConstants.HTTP_INITIALIZE_CONFIG, IntPtr.Zero);
            }

            if ((uint)ErrorCodes.NOERROR != retVal)
            {
                throw new Win32Exception(Convert.ToInt32(retVal));
            }
        }
예제 #4
0
 public static extern uint HttpDeleteServiceConfiguration(
     IntPtr ServiceIntPtr,
     HTTP_SERVICE_CONFIG_ID ConfigId,
     ref HTTP_SERVICE_CONFIG_URLACL_SET pConfigInformation,
     int ConfigInformationLength,
     IntPtr pOverlapped);