输入字段中的专有名称

时间:2019-05-21 12:09:51

标签: python flask automation pyad

Am使用Flask创建Web门户以在活动目录中创建用户。已成功测试python脚本来创建用户。我需要通过门户网站执行同样的操作,这是管理界面页面,他们将在其中提供值。

我不确定如何将OU名称传递给HTML中的变量。

@app.route('/user_creation',methods=['GET','POST'])
          def user_create():
              if(request.method=='POST'):
                  OrgU=str(request.form['Organizationalunit'])
                  FirstName=str(request.form['First-Name'])
                  Initial=str(request.form['Initials'])
                  Password=str(request.form['Password'])
                  DisplayName=str(request.form['Display-Name'])
                  Email=str(request.form['Email'])
                  pyad.set_defaults(ldap_server="XXX.com", username="Domain\XXXX", password="123")
                  ou = pyad.adcontainer.ADContainer.from_dn("OrgU")
                  new_user = pyad.aduser.ADUser.create("FirstName", ou, password="Password")
                  if(new_user):
                      #flash("user created successfully")
                      user=pyad.from_cn("new_user")
                      user.force_pwd_change_on_login()
                      user.update_attribute("displayName","DisplayName")
                      user.update_attribute("initials","Initial")
                      if(Email !='Null'):
                          user.update_attribute("mail","Email")
                      #flash("Attributes updated",'success')
                      return "user created successfully" + "<b><a href = '/user_creation'>click here to return to Input page</a></b>"
                  else:
                      return "Some error " +  "<b><a href = '/user_creation'>click here to return to Input page</a></b>"
<!-- DetailsForm -->
<div class =Welcome to Active Directory user portal>
  <form action="/user_creation" method="POST">
      <fieldset>
          <legend>Kindly Enter Details to Create User</legend><br>
          <input name="Organizationalunit" type="text" value="" placeholder="OrganizationalUnit" required/><br><br>

          <input name="First-Name" type="text" value=""  placeholder="First-Name" required/><br><br>
          <input name="Initials" type="text" value=""  placeholder="Initials" required/><br><br>
          <input name= "Password" type="text" value="" placeholder="Password" required /><br><br>
          <input name="Display-Name" type="text" value="" placeholder="Display-Name" required /><br><br>
          <input name= "Email"   type="mail" value="" placeholder="Email" /><br><br>
          <input type="submit" value="Proceed" />
      </fieldset>
  </form>
</div>

当我在字段中输入OU名称时,出现以下错误:

  

在此方面提供帮助       错误:_ds = self.adsi_provider.getObject(“,” LDAP:       文件“”,第2行,在getObject中       pywintypes.com_error:(-2147352567,'发生了异常。',(0,无,无,无,0,-2147221020),无)

0 个答案:

没有答案