title: GSSAPI and Active Directory in C#
body: <p>This may be a silly question, but is it possible to obtain GSSAPI token for current logged in user from Active Directory?</p>
  
  <p>I have a simple library that connects to server. I can pass user name, password and domain name or GSS Token (base64).
  For now first method works for me, but it is annoying to users that they must put their password.</p>
  
  <p>I couldn't find any informations about GSSAPI and it's integration with Active Directory.</p>
  
  <p>Is it possible in C#?</p>
  
  <p>Some more informations based on @Harvey Kwok comment:
  Library is called <code>Altair COM</code> and it is used for document management</p>
  
  <p>Here is some API reference about Login with GSS:</p>
  
  <pre><code>HRESULT LoginGSS(
       [in] VARIANT *token,
       [in] VARIANT_BOOL forceCreateNew,
       [out,retval] VARIANT *retToken)
  </code></pre>
  
  <p>And below is sample usage in VB:</p>
  
  <pre><code>Dim token(tokensize) As Byte 'token size-1
  ’fill token buffer
  ...
  Dim outToken() As Byte
  outToken = altair.LoginGSS(token,True)
  'if GetLastStatus == AXAPI_ALTAIR_LOGIN_CONTINUE then
  'outToken contains return GSS API token
  </code></pre>
  
  <p>And VC++ usage</p>
  
  <pre><code>SAFEARRAYBOUND sab[1];
  sab[0].lLbound=0;
  sab[0].cElements=tokensize;
  SAFEARRAY *sa;
  sa=SafeArrayCreate(VT_UI1,1,sab);
  unsigned char HUGEP *buf=NULL;
  SafeArrayAccessData(sa,(void HUGEP**)&amp;buf);
  //fill token buffer
  ...
  SafeArrayUnaccessData(sa);
  v.vt=VT_ARRAY|VT_UI1;
  v.pparray=sa;
  VARIANT vOut;
  pAltair-&gt;LoginGSS(&amp;v,true,&amp;vOut);
  SafeArrayDestroy(sa);
  'if GetLastStatus == AXAPI_ALTAIR_LOGIN_CONTINUE then
  'outToken contains return GSS API token
  </code></pre>
  
  <p>This are all informations that I have.</p>
  
  <hr>
  
  <p>I found some code snippet showing login procedure:</p>
  
  <pre><code>byte[] token;
  token = Convert.FromBase64String(tbToken.Text);
  Object o;
  o = (Object)token;
  Program.altair.LoginGSS(ref o, true);
  if ((AXAPILib.AxAPIStatus)altair.GetLastStatus()==AXAPILib.AxAPIStatus.AxAltairLoginOK)
  {
      //login ok
  }
  </code></pre>
  
  <p>But I must enter that token and I'm still trying to generate it for current user.</p>