Chinaunix首页 | 论坛 | 博客
  • 博客访问: 172569
  • 博文数量: 47
  • 博客积分: 3053
  • 博客等级: 少校
  • 技术积分: 451
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-01 04:33
个人简介

malware/APT detection, silicon valley, entrepreneur, CTO, start-up operation, team build, Nanjing/Beijing, if you want to do creative things, join the adventure.

文章分类

全部博文(47)

分类: WINDOWS

2011-08-09 06:21:22

Create User in Server 2003, using VB Script
this script doesn't work in server 2k8 due to security descriptor reason. if someone can make it work, it's awesome.

  1. Set oRoot = GetObject("LDAP://rootDSE")
  2. Set oDomain = GetObject("LDAP://" & oRoot.Get("defaultNamingContext"))

  3. Set oOU = GetObject("LDAP://ou=NDLP_Eng,DC=netdlp,DC=com")

  4. Set oUser = oOU.Create("User", "cn=Dennis Mera")
  5. oUser.Put "sAMAccountName", "DennisMera"
  6. oUser.Put "Description", "0001 Wastewater treatment plant and system operator"

  7. oUser.Put "displayName","Dennis Mera"
  8. oUser.Put "givenName", "Dennis"
  9. oUser.Put "SN", "Mera"
  10. oUser.Put "initials", "S"

  11. oUser.Put "mail", "Dennis_Mera@netdlp.com"
  12. oUser.Put "physicalDeliveryOfficeName", "Springfield"
  13. oUser.Put "url", ""

  14. oUser.Put "company",     "McAfee"
  15. oUser.Put "department", "Reconnex"
  16. oUser.Put "title", "Wastewater treatment plant and system operator"
  17. oUser.Put "manager", "cn=Ratinder Ahuja,OU=NDLP_Eng,DC=netdlp,DC=com"

  18. oUser.Put "telephoneNumber", "217-691-8192"
  19. oUser.Put "homephone",     "408 111-0001"
  20. oUser.Put "mobile", "650 222-0001"
  21. oUser.Put "pager", "408 333-0001"
  22. oUser.Put "ipPhone", "0001"
  23. oUser.Put "facsimileTelephoneNumber", "408 444-0001"
  24. oUser.Put "info", "Please do not call until 2012"

  25. oUser.Put "postalCode",     "62707"
  26. oUser.Put "streetAddress", "4504 Scenic Way"
  27. oUser.Put "st", "IL"
  28. oUser.Put "l", "Springfield"
  29. oUser.Put "c", "US"
  30. oUser.SetInfo

  31. oUser.SetPassword "Mcafee123"
  32. oUser.AccountDisabled = false
  33. oUser.SetInfo
Create User in Server 2008, using PowerShell Script
  1. # run following command first in prompt
  2. # set-executionpolicy remotesigned

  3. $objOU=[ADSI]"LDAP://ou=Deimos Engr,DC=deimos,DC=com"
  4. $dataSource=import-csv "users.csv"

  5. foreach($dataRecord in $datasource) {
  6.     $cn = $dataRecord.FirstName + " " + $dataRecord.LastName
  7.     $sAMAccountName = $dataRecord.FirstName + "." + $dataRecord.LastName
  8.     $givenName = $dataRecord.FirstName
  9.     $sn = $dataRecord.LastName
  10.     $sAMAccountName = $sAMAccountName.ToLower()
  11.     $displayName = $sn + ", " + $givenName
  12.     $userPrincipalName = $sAMAccountName + "@deimos.com"
  13.     $objUser = $objOU.Create("user","CN="+$cn)
  14.     $objUser.Put("sAMAccountName",$sAMAccountName)
  15.     $objUser.Put("userPrincipalName",$userPrincipalName)
  16.     $objUser.Put("displayName",$displayName)
  17.     $objUser.Put("givenName",$givenName)
  18.     $objUser.Put("sn",$sn)
  19.     $objUser.SetInfo()
  20.     $objUser.SetPassword("Mcafee123")
  21.     $objUser.psbase.InvokeSet("AccountDisabled",$false)
  22.     $objUser.SetInfo()
  23. }
CVS File Sample
  1. FirstName,LastName,Password
  2. Joe,Blow,Mcafee123
  3. Chris,Goat,Mcafee123
  4. Bobby,Brown,Mcafee123
  5. Matt,Johnson,Mcafee123
  6. Nick,Noob,Mcafee123

阅读(2319) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~