This blog simply records all I've learned for IT knowledge.

Thursday, July 31, 2008

Configuring windows server 2008 core basic networking settings

0. Server core has no real GUI (except a few tools such as task manager).

1. When the installation is done, login the system with Administrator and no password.

2. Managing windows 2008 server core through RDP (remote desktop protocol) client, aka mstsc:

cscript c:\windows\system32\scregedit.wsf \ar 0

(this will enable the remote desktop for Administration mode to accept connections. To view your current settings, you can type:

cscript c:\windows\system32\scregedit.wsf \ar \v

If you see "1" in the script output, that means that RDP connections are denied. If "o", they will be allowed.)

3. To enable remote management from any MMC snap-in, type the following:

netsh advfirewall firewall set rule group="Remote Desktop" new enable=yes

4. To change the name the server, first type "hostname" or "ipconfig /all" to determine the current name of the server. Then type

netdom renamecomputer /NewName:

After that, you need to restart the server by

shutdown /r /t 0

5. To set the administrator password in Windows Server 2008, type the following:

net user Administrator *

6. To set the server with static IP address, type

netsh interface ipv4 show interface

Look at the number shown in the Idx column of the output for your network adapter. If your computer has more than one network adapter, make a note of the number corresponding to the network adapter for which you wish to set a static IP address. At the command line, type:

netsh interface ipv4 set address name="" source=static address= mask= gateway=

where ID is the number shown in the Idx column.

To add DNS, type

netsh interface ipv4 add dnsserver name="" address= index=1

Repeat the above step for each DNS server that you want to set, incrementing the index=number each time.

You can verify your changes by "ipconfig /all".

7. To manager a server running a Server Core installation by using the Windows Remote Shell, you can type

WinRM quickconfig

to enable Windows Remote Shell on a server.

Then on the remote computer, at a command line, use WinRS.exe to run commands on a Server Core. For example, to perform a directory listing of the Windows folder, type

winrs -r: cmd

then you can now type any command that your require, it will be executed on the remote computer.

8. To active the server, type

slmgr.vbs -ato

to active the server remotely, type

cscript slmgr.vbs -ato

then retrieve the GUID of the computer by typing

cscript slmgr.vbs -did

type

cscript slmgr.vbs -dli

9. To join a Windows 2008 server to a domain, type

netdom join /domain: /userd: /passwordd:*

Note that entering * as the password means you will be prompted to enter it on the command prompt window in the next step. You can also enter it in the initial command, if you wish to.

After that, you need to restart the computer by "shutdown /r /t 0"

10. To remove a Windows 2008 server from a domain, type

netdom remove

Then reboot the computer.

11. change screensaver settings

type regedit and then change the following key values if needed:

* HKEY_CURRENT_USER\Control Panel\Desktop\ScreenSaveActive
* HKEY_CURRENT_USER\Control Panel\Desktop\SCRNSAVE.EXE
* HKEY_CURRENT_USER\Control Panel\Desktop\ScreenSaverIsSecure
* HKEY_CURRENT_USER\Control Panel\Desktop\ScreenSaveTimeOut

Thursday, July 24, 2008

ways to zero out file

1. cat /dev/null > file
2. echo -n "" > file

Monday, July 21, 2008

Remove data from Active Directory when the normal demotion fails for windows 2003 server

1. run "ntdsutil"
2. type "metadata cleanup"
3. type "connections"
4. type "connect to server "
5. quit and get back to "metadata cleanup" menu
6. type "select operation target"
7. type "list domains"
8. type "select domain "
9. type "list sites"
10. type "select site
11. type "list servers in site"
12. type "select server "
13. type "quit"
14. type "remove selected server"


After you remove all the data, you should be able to normally demote your AD server.

Thursday, July 17, 2008

reading material about smb

http://www.jacco2.dds.nl/samba/smb.html

Get a system dump from shell

1. Find the pid of the program
2. run "kill -s SIGQUIT pid"

Wednesday, July 16, 2008

Joining linux in windows domain

1. You need to make sure kerberos is installed:
#rpm -qa | grep krb
this should return at least 3 packages: krb5-devel, krb5-libs, and krb5-workstation

2. Make sure ldap development libs are installed:
#rpm -qa | grep ldap-devel

3. Make sure there is an entry of AD DC in /etc/hosts:
10.11.100.100 RSP1.RSPGUAM-DOMAIN.TEST RSP1

4. Edit /etc/krb5.conf based on your AD DC information. After you've modified the file, try:
#/usr/kerberos/bin/kinit Administrator@RSPGUAM-DOMAIN.TEST

If this works, you need to enter the correct password for Administrator. Otherwise, you will get the error message "kinit(v5): Preauthentication failed while getting initial credentials". If not you need double check /etc/resolv.conf and make sure the DNS server has been added.

5. Edit /etc/samba/smb.conf

workgroup = RSPGUAM-DOMAIN
realm = RSPGUAM-DOMAIN
security = ADS

6. Restart samba by "/etc/init.d/smb restart"

7. Run "net ads join -U Administrator@RSPGUAM-DOMAIN.TEST", and input the password for it.

8. Check if the computer has been added in the AD server.

a cool video about web 2.0

Tuesday, July 15, 2008

Automation in Active Directory

1. Managing user accounts

1.1 Creating user accounts

one single user by command line

dsadd user "cn=Test User,ou=sales,dc=rspguam-domain,dc=test" -samid testuser -upn testuser@rspguam-domain.test -fn Test -ln User -display "Test User" -pwd P@ssw0rd -disabled no

many users by command line

FOR /L %i in (1,1,10) DO dsadd user "cn=Test User%i,ou=sales,dc=rspguam-domain,dc=test" -samid testuser%i -upn testuser%i@rspguam-domain.test -fn Test -ln User%i -display "Test User%i" -pwd P@ssw0rd -disabled no

many users by batch file

@echo off
cls
echo Creating Accounts
echo -----------------
FOR /L %%I in (10,1,99) DO dsadd user "cn=Test User%%I,ou=sales,dc=rspguam-domain,dc=test" -samid testuser%%I -upn testuser%%I@rspguam-domain.test -fn Test -ln User%%I -display "Test User%%I" -pwd P@asswOrd -disabled no
echo -----------------
pause


1.2 Delete users in a OU

dsrm -noprompt "ou=sales,dc=rspguam-domain,dc=test" -subtree -exclude

1.3 Reset user's password

@echo off
cls
echo Reset Password
echo ---------------
set /p DN=Enter the first and last name of the user in quotes:
dsquery user -name %DN% | dsmod user -pwd NewP@sswOrd -mustchpwd yes
echo ---------------
pause

1.4 Move a user and rename the user

dsmove "cn=Test User10,ou=sales,dc=rspguam-domain,dc=test" -newparent ou=accounting,dc=rspguam-domain,dc=test -newname "Dwight Schrute"

Install fake printers on Windows 2000

Motivation: when doing automation tests, we might need fake printers.

Procedure for installation:

  1. Control Panel -> Printers -> Add Printer
  2. Select Local Printer, uncheck "Automatically detect and install my Plug and Play printer", click Next
  3. Instead of selecting an existing port, select "Create a new port" and select type as "Local Port"
  4. Enter a port name (e.g. fakeprinter. Note that the default path for this is C:\Windows\System32)
  5. Choose "Generic" as Manufacturers, and "Generic/Text Only" as Printers type (Note: you may be able to choose any other type of printer, like HP, Apple).
  6. Options: If you want to delete a printer port you just created, first delete the printer that is using the port. Then go to "Printers" windows, click "File->Server Properties->Ports". There you have authority to delete a print port.

Procedure for using the fake printer from windows cmd (lanman printing)

  1. In cmd, run "net use lpt2: \\<samba-or-windows-server>\<fake-printer-name>"
  2. Options: if you want to disconnect a mapped drive, simple type "net use x: /delete", where x: is the driver letter of the shared resource
  3. To print your file to fake printer, just use "copy lpt2" (check the file C:\Windows\System32\ to make sure it is updated)

Compatibility issue when upgrading/downgrading between vmware server 1.0.4 and vmware server 2.0

  1. fix the vmware configuration file .vmx : change the line 'virtualHW.version = "6″' to 'virtualHW.version = "4″'.
  2. fix the vmware disk configuration file .vmdk: change the line 'ddb.virtualHWVersion = "6″' to 'ddb.virtualHWVersion = "4″'.
  3. if the .vmdk is large, you may not want to directly modify the file by opening it. You can use "dd "if=source.vmdk" | sed "/virtualHWVersion = \"6\"/s//virtualHWVersion = \"4\"/" > modified.vmdk". For windows users, you can use cygwin, or uedit32.exe.

Cron

delete the log files every 5 mins by cron job
  1. edit a txt file like:
     */5 * * * * rm /tmp/vmware-admin/v*.log -f
  2. in linux, run "crontab mycron"

How to flush DNS

reference: http://www.tech-faq.com/flush-dns.shtml
  1. in windows: "ipconfig /flushdns
  2. in linux, use nscd daemon: "/etc/rc.d/init.d/nscd restart"

Installing Second Active Directory Service on Windows Server 2003