Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. Am not sure how to pass OU name to a variable in HTML.
  2.  
  3. Below is my HTML code:
  4. <!-- DetailsForm -->
  5. <body>
  6. <div class =Welcome to Active Directory user portal</div>
  7. <form action="/user_creation" method="POST">
  8. <fieldset>
  9. <legend>Kindly Enter Details to Create User</legend><br>
  10. <input name="Organizationalunit" type="text" value="" placeholder="OrganizationalUnit" required/><br><br>
  11.  
  12. <input name="First-Name" type="text" value="" placeholder="First-Name" required/><br><br>
  13. <input name="Initials" type="text" value="" placeholder="Initials" required/><br><br>
  14. <input name= "Password" type="text" value="" placeholder="Password" required /><br><br>
  15. <input name="Display-Name" type="text" value="" placeholder="Display-Name" required /><br><br>
  16. <input name= "Email" type="mail" value="" placeholder="Email" /><br><br>
  17. <input type="submit" value="Proceed" />
  18. </fieldset>
  19. </form>
  20. </div>
  21. </body>
  22.  
  23. @app.route('/user_creation',methods=['GET','POST'])
  24. def user_create():
  25. if(request.method=='POST'):
  26. OrgU=str(request.form['Organizationalunit'])
  27. FirstName=str(request.form['First-Name'])
  28. Initial=str(request.form['Initials'])
  29. Password=str(request.form['Password'])
  30. DisplayName=str(request.form['Display-Name'])
  31. Email=str(request.form['Email'])
  32. pyad.set_defaults(ldap_server="XXX.com", username="DomainXXXX", password="123")
  33. ou = pyad.adcontainer.ADContainer.from_dn("OrgU")
  34. new_user = pyad.aduser.ADUser.create("FirstName", ou, password="Password")
  35. if(new_user):
  36. #flash("user created successfully")
  37. user=pyad.from_cn("new_user")
  38. user.force_pwd_change_on_login()
  39. user.update_attribute("displayName","DisplayName")
  40. user.update_attribute("initials","Initial")
  41. if(Email !='Null'):
  42. user.update_attribute("mail","Email")
  43. #flash("Attributes updated",'success')
  44. return "user created successfully" + "<b><a href = '/user_creation'>click here to return to Input page</a></b>"
  45. else:
  46. return "Some error " + "<b><a href = '/user_creation'>click here to return to Input page</a></b>"
  47.  
  48. When i enter OU name in field, am getting below error:
  49. Appreciate help on th
  50. Error:_ds = self.adsi_provider.getObject('', "LDAP:
  51. File "<COMObject ADsNameSpaces>", line 2, in getObject
  52. pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147221020), None)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement