从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中的用户帐户。在code需要转危为安存储在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.
我已经成功地运行此code:
I have successfully run this code:
Sub CTRL1_12_OnClick(eventObj)
MsgBox "Output: "
End Sub
返回:输出:在VB对话框,当我点击我的InfoPath按钮。但是,当我尝试:
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
当我把同样的code到记事本,保存为一个VBS文件,然后执行的正常运行,并在Active Directory中的用户,我不明白的是,为什么当我运行相同的code这是行不通的。
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.
现在,我能够从按钮运行code。
Now I am able to run the code from that button.
这篇关于从InfoPath表单创建在Active Directory用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!