home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 29 / XENIATGM29.iso / ie / ie40pp1 / ie4 / wsh.cab / adduser.vbs next >
Text File  |  1996-10-21  |  2KB  |  67 lines

  1. ' Windows Script Host Sample Script
  2. '
  3. ' ------------------------------------------------------------------------
  4. '               Copyright (C) 1996 Microsoft Corporation
  5. '
  6. ' You have a royalty-free right to use, modify, reproduce and distribute
  7. ' the Sample Application Files (and/or any modified version) in any way
  8. ' you find useful, provided that you agree that Microsoft has no warranty,
  9. ' obligations or liability for any Sample Application Files.
  10. ' ------------------------------------------------------------------------
  11. '
  12. ' VBS Script to create a user
  13. '
  14. ' Syntax:  adduser.vbs /C=<country>/O=<o>/OU=<ou> accountname firstname lastname password
  15. '
  16. ' Example adduser.vbs /C=US/O=ArcadiaBay/OU=Americas PaulCezanne Paul Cezanne secret
  17. '
  18. dim con
  19. dim oArgs
  20. dim newuser
  21. dim Style
  22. dim Title
  23. dim CRLF
  24.  
  25. CRLF = Chr(13) & Chr(10)
  26.  
  27. set oArgs = WScript.Arguments
  28.  
  29. If oArgs.Count < 5 Then
  30.        Style = vbOKOnly     ' Define buttons.
  31.        Title = "Usage"      ' Define title.
  32.  
  33.        Response = MsgBox("Adds a user via OLE DS" & CRLF & CRLF & _
  34.        "Usage:" & CRLF & CRLF & _
  35.        "   adduser.vbs /C=<country>/O=<o>/OU=<ou> accountname firstname lastname password " & CRLF & CRLF & _
  36.        "Example:" & CRLF & CRLF & _
  37.        "   adduser.vbs /C=US/O=ArcadiaBay/OU=Americas PaulCezanne Paul Cezanne secret" & CRLF, _
  38.         Style, Title)
  39.     
  40.        'stop script
  41.        WScript.Quit(1)
  42. End If
  43. set oArgs = wscript.arguments
  44. set con = wscript.GetObject("LDAP:/"+oArgs.item(0))
  45. '
  46. ' make a new user
  47. '
  48. set newuser = con.create("user","CN="+oArgs.item(1))
  49. newuser.put "cn",oArgs.item(1)
  50. newuser.put "description","created from VBS!"
  51.  
  52. ' set the properties of the new user
  53. newuser.Put "givenName",oArgs.item(2) 
  54. newuser.Put "sn", oArgs.item(3)
  55. newuser.Put "sAMAccountName", oArgs.item(1)
  56. newuser.Put "User-Account-Control",16 'Enable the account
  57.  
  58. ' ...and update the DS
  59. newuser.setinfo
  60. newuser.setpassword(oArgs.item(4))
  61. wscript.echo newuser.name+" created."
  62. set newuser=nothing
  63. '
  64. ' Done
  65. '
  66.  
  67.