从 Infopath 表单在 Active Directory 中创建用户 [英] Create a user in Active Directory from an Infopath form
问题描述
我已经在网上搜索了一段时间,但似乎仍然无法找到有关此主题的任何有用信息.
I've been searching the web for a while now and still can't seem to find anything useful on this topic.
我试图在我的 Infopath 表单中创建一个按钮,它将在 Active Directory 中创建一个用户帐户.该代码需要提取存储在 Infopath 表单字段中的信息.
What I am trying to create is a button in my Infopath form that will create a user account in Active Directory. The code will need to pull through information stored in the fields of the Infopath form.
我选择使用 Visual Basic,因为我相信这是一种很好的 AD 语言脚本.
I have chosen to use Visual Basic, as I believe that is a good language scripting with AD.
我已成功运行此代码:
Sub CTRL1_12_OnClick(eventObj)
MsgBox "Output: "
End Sub
返回:'输出:',当我点击我的信息路径按钮时,在 VB 对话框中.但是,当我尝试:
which returns: 'Output: ' in a VB dialogue box when I click on my infopath button. However, when I try:
Set objOU=GetObject("LDAP://OU=People,OU=contoso,DC=contoso,DC=com")
Set objUser=objOU.Create("user","CN=Linda Mitchell")
objUser.Put "sAMAccountName","linda.mitchell"
objUser.SetInfo()
我得到的只是 Infopath 中的一条错误消息:
All I get is an error message in Infopath:
出现以下错误:
ActiveX 组件无法创建对象:'GetObject' 文件:script.vbs 行:14
ActiveX component can't create object: 'GetObject' File:script.vbs Line:14
当我将相同的代码放入记事本时,另存为 vbs 文件然后执行运行良好并在活动目录中创建用户,我不明白为什么当我运行相同的代码时它没有工作.
When I put the same code in to notepad, save as a vbs file and then execute is runs fine and create a user in active directory, what I don't understand is why when I run the same code it doesn't work.
推荐答案
我现在找到了问题所在.我需要将表单设置为完全信任"工具>表单选项>安全和信任.我还必须用我的证书在表格上签名.
I have now found out what the problem was. I needed to set the form to 'full trust' Tools>form options> Security and Trust. I also had to sign the form with my certificate.
现在我可以从那个按钮运行代码了.
Now I am able to run the code from that button.
这篇关于从 Infopath 表单在 Active Directory 中创建用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!