You are on page 1of 9

1/ tạo 1 group trong dc (ví dụ mình có 1 dc tên là hackeryou.

com)
bạn vô notepad và viết lệnh như sau
Dim noichua,group
set noichua =getobject ("LDAP://dc=hackeryou,dc=com") ' đây là đường dẫn chứa group bạn muốn tạo

set group = noichua.create("group" ,"cn=hackeryou") ' hackeryou là group mà mình muốn tạo nha

group.setinfo ' setinfo ý nghĩa là thi hành những lệnh mà ta đã khai báo ở trên
2/ tạo 1 user
Dim noichua,user
set noichua =getobject ("LDAP://dc=hackeryou,dc=com") ' đây là đường dẫn chứa group bạn muốn tạo

set user = noichua.create("user" ,"cn=abc") ' abc là user mà mình muốn tạo nha

user.setinfo ' setinfo ý nghĩa là thi hành những lệnh mà ta đã khai báo ở trên

sau khi bạn làm song


bạn save lai với dạng *.vbs sau đó chạy thử .Nếu ko thấy báo gì hết thì lệnh của bạn thành công

Hôm nay Ktv_help xin giới thiệu cho các bạn viết một đoạn chương trình mà có khả năng
tạo được hàng trăm user chỉ trong vòng 1 phút.
Trước hết bạn cần phải có 1 file danh sách chứa các tên mà bạn muốn tạo tài khoản .
Ví dụ tôi có file danh sách này tên là : userlist.txt
Lưu ý: mỗi dòng là chứa tên một user, giữa user và password cách nhau một khoảng trắng (ví dụ
tôi có cái usser là admin và password là 123 thì thôi sẽ gõ user này trên một dòng như sau
admin 123
Sau đó bạn copy đoạn code này vào notepad:
Mã:

for /f "tokens=1,2" %%x in (userlist.txt) do net user %%x %%y /add

Sau đó bạn save cái file này thành cái tên USER.BAT.
Giờ bạn hãy copy 2 file (user.bat, userlist.txt) này ra ngoài desktop chạy thử đi. Bạn
sẽ ngạc nhiên vì nó có thể tạo được hàng trăm user chỉ trong vòng 1 phút

Đoạn code trên có thể áp dụng trên cả windows xp và windows server.


Đoạn code trên nó sẽ tạo ra user Limit tức là quyền bình thường
Muốn tạo user administrator tức là quyền tối cao bạn thêm dòng
for /f %%x in (userlist.txt) do net localgroup administrators %%x /add

Hướng dẫn tạo 1000 users (đặt password, enable user...) bằng script

Yêu cầu: Trong AD Domain name: sunivy.local, tạo 1000 users


+ agent1 --> agent1000 trong OU: Agent
+ Enable 1000 users này.
+ có đặt password (ví dụ: user agent1 có pass: agent@1 --> agent1000 có pass:
agent@1000).
+ yêu cầu user đổi pass khi đăng nhập lần đầu.

Mình tạo file Script đặt tên là "Create_1000_users.vbs"


Đoạn code như sau:

Set objRootDSE = GetObject("LDAP://rootDSE")


Set objContainer = GetObject("LDAP://" & "OU=Agent," & _
objRootDSE.Get("defaultNamingContext"))

For i = 1 To 1000
Set objLeaf = objContainer.Create("User", "cn=Agent" & i)
objLeaf.Put "sAMAccountName", "agent" & i
objLeaf.Put "pwdLastSet", 0
objLeaf.SetInfo
objLeaf.SetPassword "agent@" & i
objLeaf.AccountDisabled = FASLE
objLeaf.SetInfo
Next
WScript.Echo "1000 Users created."

Đó cũng là 1 cách hay. Tuy nhiên để đơn giản hơn bạn có thể thực hiện 1 dòng lệnh
trong cmd là ok roài.

FOR /L %i IN (1,1,1000) do dsadd user "cn=Agent


%i,ou=Agent,dc=prohd,dc=com" -upn Agent%i@prohd.com -disabled no
-pwd Password@%i -mustchpwd yes

Ở đây mình dùng tên domain là prohd.com và password là: Pasword@1 ...
__________________

Tạo User bằng Command Line ngồi từ máy user connect bằng quyền admin và....

NET USER [username [password | *] [options]] [/DOMAIN]


username {password | *} /ADD [options] [/DOMAIN]
username [/DELETE] [/DOMAIN]

Ví dụ một trường hợp


NET USER THUNGHIEM /ADD sẽ add một user vào Group User với password rỗng.
NET USER TEST 123 /ADD sẽ add một user TEST với Password là 123 vào Group User hoặc
Domain user.
Chú ý, nếu chỉ sử dụng trong môi trường Group thì chỉ có thể tạo được User ở máy Local.
Nếu dùng trong môi trường Domain, mọi chuyện lại dễ.
Ngoài ra, còn những Option khi tạo User (giống như động tác click chuột trên GUI)

Options Are as follows:

Options Description
--------------------------------------------------------------------
/ACTIVE:{YES | NO} Activates or deactivates the account. If
the account is not active, the user cannot
access the server. The default is YES.
/COMMENT:"text" Provides a descriptive comment about the
user's account (maximum of 48 characters).
Enclose the text in quotation marks.
/COUNTRYCODE:nnn Uses the operating system country code to
implement the specified language files for a
user's help and error messages. A value of
0 signifies the default country code.
/EXPIRES:{date | NEVER} Causes the account to expire if date is
set. NEVER sets no time limit on the
account. An expiration date is in the
form mm/dd/yy or dd/mm/yy, depending on the
country code. Months can be a number,
spelled out, or abbreviated with three
letters. Year can be two or four numbers.
Use slashes(/) (no spaces) to separate
parts of the date.
/FULLNAME:"name" Is a user's full name (rather than a
username). Enclose the name in quotation
marks.
/HOMEDIR:pathname Sets the path for the user's home directory.
The path must exist.
/PASSWORDCHG:{YES | NO} Specifies whether users can change their
own password. The default is YES.
/PASSWORDREQ:{YES | NO} Specifies whether a user account must have
a password. The default is YES.
/PROFILEPATH[:path] Sets a path for the user's logon profile.
/SCRIPTPATH:pathname Is the location of the user's logon
script.
/TIMES:{times | ALL} Is the logon hours. TIMES is expressed as
day[-day][,day[-day]],time[-time][,time
[-time]], limited to 1-hour increments.
Days can be spelled out or abbreviated.
Hours can be 12- or 24-hour notation. For
12-hour notation, use am, pm, a.m., or
p.m. ALL means a user can always log on,
and a blank value means a user can never
log on. Separate day and time entries with
a comma, and separate multiple day and time
entries with a semicolon.
/USERCOMMENT:"text" Lets an administrator add or change the User
Comment for the account.
/WORKSTATIONS:{computername[,...] | *}
Lists as many as eight computers from
which a user can log on to the network. If
/WORKSTATIONS has no list or if the list is *,
the user can log on from any computer.

Những Option trên chính là những phần Click chuột mà bạn thường hay sử dụng khi tạo trong
Computer management, hoặc là dùng AD Computer and Users.

Ứng dụng tốt nhất của việc dùng Command line là: Bạn có thể tạo ra cùng một lúc nhiều User có
chức năng tương tự nhau, bạn chỉ mất khoảng thời gian Edit và Test command đầu tiên, sau đó
chỉ việc Copy và chỉnh sửa chút xíu, là có thể tạo thành một Teplate hoàn chỉnh rồi.

Cấu Hình IP bằng command line


Để cấu hình địa chỉ IP, DNS, WIN bằng command line.
Các bạn thực hiện các bước sau:
Vào của sổ command prompt.
gõ lệnh:
netsh <Enter>
interface IP <Enter>

<--Set IP Address-->
set address name= "Local Area Connection" source=dhcp <Enter>
set address local static <IP Address> <IP Supnet Mask <Enter>
vidu:
set address name= "Local Area Connection" source=dhcp <Enter>
set address local static 192.168.1.2 255.255.255.0 <Enter>

<--Set Preferred DNS Server -->


set dns name= "Local Area Connection" source=dhcp <Enter>
set DNS Local Area Connection" static <IP Address DNS> <Enter>

vidu:
set dns name= "Local Area Connection" source=dhcp <Enter>
set DNS "Local Area Connection" static 192.168.1.1 <Enter>

<--Set WINS address-->


set wins name= "Local Area Connection" source=dhcp <Enter>
set wins Local Area Connection" static <IP Address WINS> <Enter>

vidu:
set wins name= "Local Area Connection" source=dhcp <Enter>
set wins "Local Area Connection" static 192.168.1.1 <Enter>

<--De thoat khoi chuong trinh--->

Exit <Enter>

Bài này là bài dịch nhưng được lão thầy em chỉnh sửa lại.Hôm nay mới dám đưa lên cho các lão
them khảo.

ShutDown một máy tính trong môi trường mạng từ xa(chỉ xải công cụ trong Windows) thì đòi
hỏi một số yêu cầu sau :
1. Về công cụ để thực hiện : - Terminal Service
- hoặc NetMeeting application
- Computer Management
- Windows Command : SHUTDOWN trong bộ Resource Kit
2. Yêu cầu về quyền hạn của người dùng :
Tốt hơn hết, bạn có quyền Administrator trong môi trường mạng. Ví dụ: thuộc nhóm
Administrators hoặc Domain Admin. Chú ý : một máy đã tham gia môi trường domain thì bao
giờ bạn cũng có thể shutdown nó cho dù bạn không có username và password của
Administrators locally.
HƯỚNG DẪN THỰC HÀNH : Sử dụng COMPUTER MANAGEMENT
Yêu cầu : Cần thiết lập môi trường domain để thấy được sự tối ưu khi triển khai quản trị hệ
thống mạng. Giả sử trong mạng có các máy: PC1, PC2 tham gia môi trường domain MCP.COM
và máy DOMAIN CONTROLLER DC1
Các bước cụ thể :
1. Logon ở máy PC1 bằng tàu khoản thangdiablo@mcp.com(thuộc nhóm Domain Users). Chú ý
tài khoản này không có quyền hạn gì cả. Nhưng chúng ta sẽ sử dụng RUNAS với tài khoản là
administrator@mcp.com để làm thao tác shutdown máy PC2
2. Vào RUN gõ : runas /user:administrator@mcp.com "mmc %systemroot
%/system32/compmgmt.msc"
SAU ĐÓ : gõ password của administartor@mcp.com
3. Ở Computer Management[với quyền administrator@mcp.com], Chọn mục : CONNECT TO
ANOTHER COMPUTER, gõ IP của PC2 hoặc tên máy là PC2.
Chọn PROPERTIES | tab Advanced| tab STARTUP and RECOVERY | tab SHUTDOWN và ....
SHUTDOWN máy PC2.
4. Hết rồi
Chúc các bạn thử thành công.
PS : Chú ý là vừa sử dụng RUNAS vừa SHUTDOWN từ xa.

Nói về commandline, tui xin góp 1 lệnh nhé (sưu tầm từ VN-STUDY.com)
-----------------------------------------------------------------------------------------
C:\>nslookup
Default Server: hcm-server1.vnn.vn
Address: 203.162.4.1
Aliases: 1.4.162.203.in-addr.arpa
Cho bieát DNS server mà client gởi query lên ở đâu !!?

C:\>nslookup ?
Usage:
nslookup [-opt ...] # interactive mode using default server
nslookup [-opt ...] - server # interactive mode using 'server'
nslookup [-opt ...] host # just look up 'host' using default server
nslookup [-opt ...] host server # just look up 'host' using 'server'

C:\>nslookup www.yahoo.com
Server: hcm-server1.vnn.vn
Address: 203.162.4.1
Aliases: 1.4.162.203.in-addr.arpa

Non-authoritative answer:
Name: www.yahoo.akadns.net
Addresses: 66.94.230.35, 66.94.230.32, 66.94.230.41, 66.94.230.46
66.94.230.39, 66.94.230.38, 66.94.230.42, 66.94.230.45
Aliases: www.yahoo.com
Query www.yahoo.com record từ client đến server

Tìm kiếm các record MX, NS, A, SOA, CNAME, . . . của một server bằng NSLOOKUP

C:\>nslookup
Default Server: hcm-server1.vnn.vn
Address: 203.162.4.1
Aliases: 1.4.162.203.in-addr.arpa

> set type=MX


> yahoo.com
Server: hcm-server1.vnn.vn
Address: 203.162.4.1
Aliases: 1.4.162.203.in-addr.arpa

Non-authoritative answer:
yahoo.com.vn-study.com MX preference = 10, mail exchanger = mail.vn-study.com

vn-study.com nameserver = dns1.name-services.com


vn-study.com nameserver = dns2.name-services.com
vn-study.com nameserver = dns3.name-services.com
vn-study.com nameserver = dns4.name-services.com
vn-study.com nameserver = dns5.name-services.com
mail.vn-study.com internet address = 203.162.2.17
dns1.name-services.com internet address = 63.251.163.102
dns2.name-services.com internet address = 216.52.184.230
dns3.name-services.com internet address = 63.251.83.36
dns4.name-services.com internet address = 64.74.96.242
dns5.name-services.com internet address = 212.118.243.99
dns5.name-services.com internet address = 212.118.243.100
dns5.name-services.com internet address = 212.118.243.101
Query MX record : danh saùch mail server

> set type=A


> yahoo.com
Server: hcm-server1.vnn.vn
Address: 203.162.4.1
Aliases: 1.4.162.203.in-addr.arpa

Non-authoritative answer:
Name: yahoo.com
Address: 66.218.71.198
Query A record(Host) cuûa moät server

> set type=SOA


> yahoo.com
Server: hcm-server1.vnn.vn
Address: 203.162.4.1
Aliases: 1.4.162.203.in-addr.arpa

DNS request timed out.


timeout was 2 seconds.
Non-authoritative answer:
yahoo.com
primary name server = hidden-master.yahoo.com
responsible mail addr = hostmaster.yahoo-inc.com
serial = 2004021604
refresh = 900 (15 mins)
retry = 300 (5 mins)
expire = 604800 (7 days)
default TTL = 600 (10 mins)

yahoo.com nameserver = ns1.yahoo.com


yahoo.com nameserver = ns2.yahoo.com
yahoo.com nameserver = ns3.yahoo.com
yahoo.com nameserver = ns4.yahoo.com
yahoo.com nameserver = ns5.yahoo.com
ns1.yahoo.com internet address = 66.218.71.63
ns2.yahoo.com internet address = 66.163.169.170
ns3.yahoo.com internet address = 217.12.4.104
ns4.yahoo.com internet address = 63.250.206.138
ns5.yahoo.com internet address = 216.109.116.17
>
Query SOA record, coù ñöôïc nhöõng thoâng soá replication cuûa server yahoo.com

C:\>nslookup
Default Server: hcm-server1.vnn.vn
Address: 203.162.4.1
Aliases: 1.4.162.203.in-addr.arpa

> server www.yahoo.com


Default Server: www.yahoo.akadns.net
Addresses: 66.94.230.42, 66.94.230.44, 66.94.230.34, 66.94.230.41
66.94.230.33, 66.94.230.36, 66.94.230.43, 66.94.230.39
Aliases: www.yahoo.com
>

C:\>nslookup

>ls [-a, d, t type ] domain [>filename]


---------------------------------------------------------------------
Còn gì nữa không nhỉ

Còn nữa nè: Các lệnh truy cập vào admin tools:
-------------------------------------------------------------
AD Domains & Trusts domain.msc
AD Sites & Services dssites.msc
AD Schema Manager schmmgmt.msc
AD Users & Computer dsa.msc
Backup backup
Certification Authority certsrv.msc
Component Services comexp.msc
Computer Management compmgmt.msc
DHCP dhcpmgmt.msc
Distributed File System dfsgui.msc
DNS dnsmgmt.msc
Domain Controller Security Policy dcpol.msc
Domain Security Policy dompol.msc
Event Viewer eventvwr
Indexing Service ciadv.msc
Internet Authentication Service ias.msc
Internet Service Manager iis.msc
Local Security Policy secpol.msc
Network Monitor netmon
Routing & Remote Access rasmgmt.msc
Task Manager taskmgr
Telnet Server Administration tlntadmn
Terminal Service Manager tsadmin
Terminal Service Client mstsc
okie còn đây là cách lên DC các pác tham khảo:

[DCINSTALL]
ReplicaOrNewDomain=Domain
TreeOrChird=Tree
CreateOrJoin=Create
NewDomainDNSName=cobacang.com
DNSOnNetwork=yes
DomainNetbiosName=cobacang
AutoConfigDNS=yes
AllowAnonymousAccess=no
DatabasePath=%systemroot%\ntds
LogPath=%systemroot%\ntds
SYSVOLPath=%systemroot%\sysvol
SafeModeAdminPassword=
CriticalReplicationOnly=no
RebootOnSuccess=yes
Còn đây nửa, service control (SC) - Only Win2003 Server:
cú pháp: sc [ServerName] Command ServiceName [OptionName= OptionValue]
Một ví dụ cụ thể - Run Telnet Service từ máy server:
sc \\servername start tlntsvr
(chú ý: tlntsvr là keynaem của Telnet, nếu bạn không biết key thì có thể dùng lệnh sau để lấy
service key: sc getkeyname service name -> ví dụ:
sc \\server "Routing and remote access" sẽ cho ra keyname là remoteaccess).
Nếu lỡ cái service telnet đó bị disable rùi thì đây:
sc \\servername config tlntsvr start= auto
(nhớ là giữa dấu = và auto có space)
Xem trang thai cua service : sc \\servername query tlntsvr

--
nguồn HVA
--
Hiểu thì hiểu, không hiểu cũng đừng có hỏi tôi. Tài liệu này tôi post llên đây vì phải format máy
tính ở nhà lại. Để dành vài bữa chép về lại máy nghiên cứu.

You might also like