开发者

Get web authentication info with ActiveX

开发者 https://www.devze.com 2023-04-05 00:17 出处:网络
At my job (Windows / IE), we login in a given domain (DOM1) and need to use 开发者_Go百科a Sharepoint server in another one (DOM2).

At my job (Windows / IE), we login in a given domain (DOM1) and need to use 开发者_Go百科a Sharepoint server in another one (DOM2).

I have put together a mix of C# and AutoHotKey in order to pass data from the Sharepoint to SAP. So far it works ok, but now I am facing the issue of authenticating in the SP domain. In order to avoid a hard-coded (or DPAPI protected) common username/password, I would like to get to use the authentication data from the browser.

I have little experience with ActiveX but I think I can convert my program to it, but I do not know if I will be able to get the authentication data from the IE (and how do it).

If I launch an ActiveX from a web page, can it get the authentication data from the IE session? Which API/Interface/function must be used?


If you instantiate the ActiveX control in the web page, you can interact between IE and the ActiveX object. You must place the ActiveX object somewhere in the <body>. Here's how I do it:

<object id="OBJID" align="center" classid="clsid:[GUID of ActiveX]" style="z-index:0" codebase="http://yourdomain.com/path/ActiveXName.cab#version=x,x,x,x" height="300" hspace="0" vspce="0" width="250">

You must wire the ActiveX methods to Javascript methods, like this:

<script language="javascript" event="ActiveXMethod" for="OBJID">LocalJSMethodName();</script>

When the ActiveX control loads, you can call a wired method to execute the Javascript method, which can push the authentication data (if it is browser side) back to the ActiveX control. The Javascript can access the ActiveX properties like this:

To assign values:

document.OBJID.PropName = 'Some Value';

To retrieve values:

var x = document.OBJID.PropName;

You should note that an ActiveX object must be signed with a code signing certificate or Internet Explorer will block it, and most times won't give you the option of overriding the block and loading it...

I hope this helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号