Red Gate forums :: View topic - Invalid handle from InitializeSecurityContext
Return to RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
PInvoke.Net forum

Invalid handle from InitializeSecurityContext

Search in PInvoke.Net forum
Post new topic   Reply to topic
Jump to:  
Author Message

Joined: 04 Mar 2010
Posts: 1

PostPosted: Thu Mar 04, 2010 7:29 pm    Post subject: Invalid handle from InitializeSecurityContext Reply with quote

Hi All,

I went thorugh the code in

Instead of kerberos authentication, i wish to implement Windows authentication . I modifed the AcquireCredentials method as follows:


returnValue = AcquireCredentialsHandle(_sAccountName, "NTLM", SECPKG_CRED_OUTBOUND,
                                                           HANDLE.Zero, HANDLE.Zero, HANDLE.Zero, HANDLE.Zero,
                                                           ref _hOutboundCred, ref ClientLifeTime);

I got returnvalue zero for above method call.

But the initializeSecurityContext returns SEC_E_INVALID_HANDLE. Please see below code :


ss = InitializeSecurityContext(ref _hOutboundCred,
                       _sAccountName, // null string pszTargetName,
                        0,//int Reserved1,
                        SECURITY_NETWORK_DREP, //int TargetDataRep
                        IntPtr.Zero,    //Always zero first time around...
                        0, //int Reserved2,
                        out _hClientContext, //pHandle CtxtHandle = SecHandle
                        out ClientToken,//ref SecBufferDesc pOutput, //PSecBufferDesc
                        out ContextAttributes,//ref int pfContextAttr,
                        out ClientLifeTime); //ref IntPtr ptsExpiry ); //PTimeStamp

Please help me in this regard.
Back to top
View user's profile Send private message

Joined: 03 Feb 2010
Posts: 83
Location: Cambridgeshire

PostPosted: Wed Mar 10, 2010 7:10 pm    Post subject: Reply with quote

SEC_E_INVALID_HANDLE will be returned if the _hOutboundCred handle is either null or is not valid.
The one thing to check if you are basing your code on the example is that both the client and server are using NTLM authenitication.

If this is not the problem then let us know and we can look a bit deeper into your code.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group