Dispose() public method

public Dispose ( ) : void
return void
Exemplo n.º 1
0
Arquivo: SSPI.cs Projeto: BjkGkh/R106
    void InitializeClient(out byte[] clientBlob, byte[] serverBlob,
        out bool continueProcessing)
    {
      clientBlob = null;
      continueProcessing = true;
      SecBufferDesc clientBufferDesc = new SecBufferDesc(MAX_TOKEN_SIZE);
      SECURITY_INTEGER lifetime = new SECURITY_INTEGER(0);
      int ss = -1;
      try
      {
        uint ContextAttributes = 0;

        if (serverBlob == null)
        {
          ss = InitializeSecurityContext(
              ref outboundCredentials,
              IntPtr.Zero,
              targetName,
              STANDARD_CONTEXT_ATTRIBUTES,
              0,
              SECURITY_NETWORK_DREP,
              IntPtr.Zero, /* always zero first time around */
              0,
              out clientContext,
              out clientBufferDesc,
              out ContextAttributes,
              out lifetime);

        }
        else
        {
          String s = System.Text.Encoding.UTF8.GetString(serverBlob, 0,
              serverBlob.Length);
          SecBufferDesc serverBufferDesc = new SecBufferDesc(serverBlob);

          try
          {
            ss = InitializeSecurityContext(ref outboundCredentials,
                ref clientContext,
                targetName,
                STANDARD_CONTEXT_ATTRIBUTES,
                0,
                SECURITY_NETWORK_DREP,
                ref serverBufferDesc,
                0,
                out clientContext,
                out clientBufferDesc,
                out ContextAttributes,
                out lifetime);
          }
          finally
          {
            serverBufferDesc.Dispose();
          }
        }


        if ((SEC_I_COMPLETE_NEEDED == ss)
            || (SEC_I_COMPLETE_AND_CONTINUE == ss))
        {
          CompleteAuthToken(ref clientContext, ref clientBufferDesc);
        }

        if (ss != SEC_E_OK &&
            ss != SEC_I_CONTINUE_NEEDED &&
            ss != SEC_I_COMPLETE_NEEDED &&
            ss != SEC_I_COMPLETE_AND_CONTINUE)
        {
          throw new MySqlException(
              "InitializeSecurityContext() failed  with errorcode " + ss);
        }

        clientBlob = clientBufferDesc.GetSecBufferByteArray();
      }
      finally
      {
        clientBufferDesc.Dispose();
      }
      continueProcessing = (ss != SEC_E_OK && ss != SEC_I_COMPLETE_NEEDED);
    }
Exemplo n.º 2
0
        void InitializeClient(out byte[] clientBlob, byte[] serverBlob,
                              out bool continueProcessing)
        {
            clientBlob         = null;
            continueProcessing = true;
            SecBufferDesc    clientBufferDesc = new SecBufferDesc(MAX_TOKEN_SIZE);
            SECURITY_INTEGER lifetime         = new SECURITY_INTEGER(0);
            int ss = -1;

            try
            {
                uint ContextAttributes = 0;

                if (serverBlob == null)
                {
                    ss = InitializeSecurityContext(
                        ref outboundCredentials,
                        IntPtr.Zero,
                        targetName,
                        STANDARD_CONTEXT_ATTRIBUTES,
                        0,
                        SECURITY_NETWORK_DREP,
                        IntPtr.Zero, /* always zero first time around */
                        0,
                        out clientContext,
                        out clientBufferDesc,
                        out ContextAttributes,
                        out lifetime);
                }
                else
                {
                    String s = System.Text.Encoding.UTF8.GetString(serverBlob, 0,
                                                                   serverBlob.Length);
                    SecBufferDesc serverBufferDesc = new SecBufferDesc(serverBlob);

                    try
                    {
                        ss = InitializeSecurityContext(ref outboundCredentials,
                                                       ref clientContext,
                                                       targetName,
                                                       STANDARD_CONTEXT_ATTRIBUTES,
                                                       0,
                                                       SECURITY_NETWORK_DREP,
                                                       ref serverBufferDesc,
                                                       0,
                                                       out clientContext,
                                                       out clientBufferDesc,
                                                       out ContextAttributes,
                                                       out lifetime);
                    }
                    finally
                    {
                        serverBufferDesc.Dispose();
                    }
                }


                if ((SEC_I_COMPLETE_NEEDED == ss) ||
                    (SEC_I_COMPLETE_AND_CONTINUE == ss))
                {
                    CompleteAuthToken(ref clientContext, ref clientBufferDesc);
                }

                if (ss != SEC_E_OK &&
                    ss != SEC_I_CONTINUE_NEEDED &&
                    ss != SEC_I_COMPLETE_NEEDED &&
                    ss != SEC_I_COMPLETE_AND_CONTINUE)
                {
                    throw new MySqlException(
                              "InitializeSecurityContext() failed  with errorcode " + ss);
                }

                clientBlob = clientBufferDesc.GetSecBufferByteArray();
            }
            finally
            {
                clientBufferDesc.Dispose();
            }
            continueProcessing = (ss != SEC_E_OK && ss != SEC_I_COMPLETE_NEEDED);
        }