简体   繁体   English

从javascript或vbscript调用CryptProtectData函数

[英]calling CryptProtectData function from javascript or vbscript

I am creating a site where users can save different credentials and while logging to a VM, they can simply choose to log in using a particular credential. 我正在创建一个站点,用户可以在其中保存不同的凭据,并且在登录到VM时,他们可以选择使用特定的凭据登录。 Therefore, I have to generate a rdp file containing the username/password selected. 因此,我必须生成一个包含所选用户名/密码的rdp文件。 That is fine, but the problem is the password in a rdp file needs to be encrypted using CryptProtectData function found in crypt32.dll. 很好,但是问题是rdp文件中的密码需要使用crypt32.dll中的CryptProtectData函数进行加密。 This can be done without a sweat but the problem is the file can be decrypted only on that computer on which it was created. 可以不费吹灰之力地完成此操作,但是问题是只能在创建该文件的计算机上解密该文件。

Therefore, even if I create a rdp file on the fly and send it to the clients, they are not able to open it as it was not created on their machine. 因此,即使我即时创建了rdp文件并将其发送给客户端,他们也无法打开该文件,因为它不是在其计算机上创建的。 So, I have to somehow encrypt the password from the client side and generate the rdp file. 因此,我必须以某种方式从客户端加密密码并生成rdp文件。 But I can't get to know how do I call functions of COM objects from the client side. 但是我不知道如何从客户端调用COM对象的函数。

Please help. 请帮忙。

The solution is to not do this. 解决的办法是不这样做。 Instead, generate the RDP file with no password, and train the users to check the box to save the credentials on their machine. 而是,生成没有密码的RDP文件,并培训用户选中该复选框以将凭据保存在他们的计算机上。

Set prompt for credentials:i:0 , and the user will be prompted for username and password on the first occasion. 设置prompt for credentials:i:0 ,并且第一次提示用户输入用户名和密码。 They will have the opportunity to check a box to save the credentials, and will not be asked again on subsequent occasions. 他们将有机会选择一个复选框来保存凭据,并且在以后的情况下不会再被询问。

Note that you can't call CryptProtectData from within a browser. 请注意,您无法在浏览器中调用CryptProtectData。 If you cannot install software on the user's machine, or have the user do it, you cannot do this at all. 如果您无法在用户的计算机上安装软件或让用户执行该软件,则根本无法执行此操作。

There used to be a capability to do this but it was removed in XPSP2 and 2003SP1. 曾经有能力做到这一点,但是在XPSP2和2003SP1中已将其删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM