/// <summary>
        /// Coes the set proxy blanket.
        /// </summary>
        /// <param name="proxy">The proxy.</param>
        /// <param name="dwAuthnSvc">The dw authn SVC.</param>
        /// <param name="dwAuthzSvc">The dw authz SVC.</param>
        /// <param name="pServerPrincName">Name of the p server princ.</param>
        /// <param name="dwAuthnLevel">The dw authn level.</param>
        /// <param name="dwImpLevel">The dw imp level.</param>
        /// <param name="pAuthInfo">The p authentication information.</param>
        /// <param name="dwCapababilities">The dw capababilities.</param>
        /// <param name="throwOnError">if set to <c>true</c> [throw on error].</param>
        /// <returns>System.Int32.</returns>
        /// <exception cref="COMException">CoSetProxyBlanket failed with HRESULT {hr:X}</exception>
        private static int CoSetProxyBlanket(IntPtr proxy,
                                             uint dwAuthnSvc,
                                             uint dwAuthzSvc,
                                             string pServerPrincName,
                                             RpcAuthnLevel dwAuthnLevel,
                                             RpcImpLevel dwImpLevel,
                                             IntPtr pAuthInfo,
                                             OleAuthCapabilities dwCapababilities,
                                             bool throwOnError)
        {
            //should be called once for process to be able to call into ecs com api's
            int hr = Win32Helper.CoSetProxyBlanket(
                proxy,
                dwAuthnSvc,
                dwAuthzSvc,
                pServerPrincName,
                dwAuthnLevel,
                dwImpLevel,
                pAuthInfo,
                dwCapababilities);

            //expected is 0
            if (HResult.Failed(hr) && throwOnError)
            {
                throw new COMException($"{StorageSyncResources.ComError1} {hr:X}");
            }

            return(hr);
        }
Example #2
0
 public static extern int CoSetProxyBlanket(
     IntPtr pProxy,
     uint dwAuthnSvc,
     uint dwAuthzSvc,
     string pServerPrincName,
     RpcAuthnLevel dwAuthnLevel,
     RpcImpLevel dwImpLevel,
     IntPtr pAuthInfo,
     OleAuthCapabilities dwCapababilities);
 /// <summary>
 /// Coes the set proxy blanket.
 /// </summary>
 /// <param name="proxy">The proxy.</param>
 /// <param name="dwAuthnSvc">The dw authn SVC.</param>
 /// <param name="dwAuthzSvc">The dw authz SVC.</param>
 /// <param name="pServerPrincName">Name of the p server princ.</param>
 /// <param name="dwAuthnLevel">The dw authn level.</param>
 /// <param name="dwImpLevel">The dw imp level.</param>
 /// <param name="dwCapababilities">The dw capababilities.</param>
 /// <param name="exception">if set to <c>true</c> [exception].</param>
 /// <returns>System.Int32.</returns>
 private static int CoSetProxyBlanket(IntPtr proxy,
                                      uint dwAuthnSvc                      = ManagementInteropConstants.RPC_C_AUTHN_DEFAULT,
                                      uint dwAuthzSvc                      = ManagementInteropConstants.RPC_C_AUTHZ_NONE,
                                      string pServerPrincName              = null,
                                      RpcAuthnLevel dwAuthnLevel           = RpcAuthnLevel.Default,
                                      RpcImpLevel dwImpLevel               = RpcImpLevel.Impersonate,
                                      OleAuthCapabilities dwCapababilities = OleAuthCapabilities.EOACNONE,
                                      bool exception = true)
 {
     return(CoSetProxyBlanket(
                proxy,
                dwAuthnSvc,
                dwAuthzSvc,
                pServerPrincName,
                dwAuthnLevel,
                dwImpLevel,
                IntPtr.Zero,
                dwCapababilities,
                exception));
 }