I was able to get this working on heimdal by using the following code:

````ruby
      ctx = pctx.get_pointer(0)
      case LibGSSAPI::GSSAPI_LIB_TYPE 
      when :heimdal
        @context = ctx
      when :mit
        @context = LibGSSAPI::GssCtxIdT.new(ctx) if ctx != @context
      end
````