Last active
April 20, 2017 14:53
-
-
Save danesparza/6172e5d0e8ca03094849a5b2bac461d4 to your computer and use it in GitHub Desktop.
Using OLE to provide windows authenticated http requests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
ole "github.com/go-ole/go-ole" | |
"github.com/go-ole/go-ole/oleutil" | |
) | |
func main() { | |
ole.CoInitialize(0) | |
defer ole.CoUninitialize() | |
unknown, _ := oleutil.CreateObject("WinHTTP.WinHTTPRequest.5.1") | |
request, _ := unknown.QueryInterface(ole.IID_IDispatch) | |
oleutil.CallMethod(request, "SetAutoLogonPolicy", 0) | |
oleutil.CallMethod(request, "Open", "GET", "http://your-windows-authenticated/website", false) | |
oleutil.CallMethod(request, "Send") | |
resp := oleutil.MustGetProperty(request, "ResponseText") | |
fmt.Println(resp.ToString()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ugly (since you're essentially relying on the Windows subsystem to create a browser request), but confirmed it works -- when other solutions haven't.