Search This Blog

Tuesday, December 18, 2012

Active Directory | LDAP - DSQuery user






DSQuery user

Search for users in active directory.

Syntax
    DSQuery User [{StartNode | forestroot | domainroot}] [-o {dn | rdn | samid}] [-scope {subtree | onelevel | base}] [-name Name] [-desc Description] [-upn UPN] [-samid Filter] [-inactive NumberOfWeeks] [-stalepwd NumberOfDays] [-disabled] [{-s Server | -d Domain}] [-u UserName] [-p {Password | *}] [-q] [-r] [-gc] [-limit NumberOfObjects] [{-uc | -uco | -uci}]
Key
         StartNode | forestroot | domainroot The node in the console tree where the search starts. forestroot = search using the global catalog.

-o                               The format used to display the search results.
                                    dn = distinguished name.
                                    rdn = relative distinguished name.
                                    samid = Security Accounts Manager (SAM) account name.

-scope                     The scope of the search:
                                     subtree = subtree that is rooted at the start node in the console tree.
                                     onelevel = immediate children of the start node only.
                                     base = single object that the start node represents.
                                     If forestroot is the StartNode, then subtree is the only valid scope.

-name                        Search for user(s) whose name attribute(CN) matches Name.
                                     For example, "br*"

-desc                              Search for user(s) whose description matches. For example, "contractor*"

 -upn                                Users whose UPN attribute matches UPN

 -samid                           User(s) whose SAM account name matches SAMName

 -inactive                    Users who have been inactive for n number of weeks

-stalepwd                     Users who have not changed their passwords for n days

-disabled                    Users with disabled accounts

 -s                                     Server to connect to (Default=the domain controller in the logon domain.)

 -d                                     Domain to connect to.

 -u                                     Username with which the user logs on to a remote server.

 -p                                       Password (UserName or Domain\UserName or Username@domain.com)

 -q                                     Quiet, suppress all output

 -r                                     Recursive search (follow referrals)

 -gc                                    Use the AD global catalog during the search.

 -limit                             The maximum number of objects to return, default=100.

 -uc                                    Unicode format

 -uco                                Unicode format for output only

 -uci                                  Unicode format for input only

Examples

Find all inactive accounts (more than 4 weeks inactive)

C:\> dsquery user -inactive 4

Disable all inactive accounts (more than 4 weeks inactive)

C:\> dsquery user -inactive 4 | dsmod user -disabled yes

Export all active users to .txt file.

C:\> dsquery user -limit 1000 -o rdn -name * > c:\all_users.txt

Export all disabled users to .txt file.

C:\> dsquery user -limit 1000 -o rdn -disabled -name * > c:\all_disabled_users.txt

Tuesday, June 5, 2012

phpinfo - how to create info file?

PHP Info


This file can help you to identify which php modules/extensions installed and enabled on your server.
This solution very simple.
Step 1.
Connect to the server through SSH and be sure you have root credentials.
Navigate to public_html directory.
cd /home/websiteuser/public_html
Step 2.
Create file.
nano phpinfo.php
Copy to the file code below:


<?php  
phpinfo(); 
?> 
Save and quit from file editor.
Step 3.
Let's check file permissions and owner.

root@server [/home/ websiteuser/public_html]# ls -l | grep phpinfo
-rw-------  1 root  root      24 Jun  5 13:34 phpinfo.php

As you see, owner of this file root, because we created this file under user root.
Change ownership:
chown websiteuser.websiteuser phpinfo.php
Change permissions:
chmod 644 phpinfo.php

Step 4.
Browse to this file from browser.
http://websiteuser.com/phpinfo.php

Now you see information page of apache & php. All modules and extensions.

eNj0Y!


WINSXS folder - How to clean up? (Windows 2008 R2 / Windows 7)

Windows 2008 R2 WINSXS folder

SP1 MUST BE INSTALLLED!

1) Install Service Pack 1

2) Start command prompt

3) Run DISM command: DISM.exe /online /Cleanup-Image /spsuperseded


4) wait few minutes (5-10m)

5) check you disk space!

eNj0Y!

Wednesday, May 23, 2012

Service stuck in "starting" or "stopping" state.

Windows  Service stucking problem.

Many times, service stuck and we don't know what to do with this issue.
If your server is production and you can't reboot him right now, but you must start or stop the specific service - this post for you.


1. Open command prompt
Let's find your service and identify the PID.
If you already know the name of service, run next command:

sc queryex w32Time

and you will see PID number.
If you don't know name of the service, just run same command without name of the service.

sc queryex

you will see list of all services, just find what you need.

2. Let's kill the service.
Now you know PID of the service and let's kill him!

taskkill /f /pid 1132

That's all.

enJoY!

Tuesday, May 22, 2012

Windows Server 2008/2008 R2 Administrator's password reset.

How to reset administrator's password in windows server 2008?


Step 1
a) Insert DVD disk of Windows Server 2008
b) Boot from DVD disk
c) Navigate to "Repair your computer"

d) Choose first option ("Use recovery tools that can........")

e) Choose recovery tool:  "Command Prompt"

f) Enter commands like on screenshot below.

g) Click on "Restart"

Step 2
a) Click on utils button

b) Follow the screenshot below

c) Now you can login to server with Administrator withou any problems.

DON'T FORGET TO CHANGE UTILMAN.EXE BACK!!
Go to step 1. and open "Command Prompt"
Enter next commands to change back your utilman.exe
d:
cd windows/system32
move utilman.exe.bak utilman.exe

RESTART

eNj0Y!

Wednesday, May 16, 2012

mod_deflate configuration. Error playing .swf (flash)

Apache v2 module Deflate.

Today I stuck on something very strange.
Server whom I worked on it, run's WHM and on one of the websites, I saw follow issue:
Main page running .swf files, I mean flash. When I open the website in google chrome and internet explorer,  I see blank grey page while in FIREFOX it works fine.

               What is the problem here?

First I checked which modules installed on this server by httpd –l command.
Afterwards, I dug from network something interesting and I tried to resolve this issue. So better  Keep it for your self.
On this server installed mod_delflate.

Quote from WIKI:
"mod_deflate is an optional module for the Apache HTTP Server, Apache v2 only. Based on Deflate lossless data compression algorithm that uses a combination of the LZ77 algorithm and Huffman coding.This module provides the DEFLATE output filter that allows output from Apache HTTP server to be compressed before being sent to the client over the network.It also provides a filter for decompressing (inflating, uncompressing) a gzip compressed response body.The mod_deflate module does not have a lower bound for file size, so it attempts to compress files that are too small to benefit from compression. This results in files smaller than approximately 120 bytes becoming larger when processed by mod_deflate"
To resolve this problem, you need to edit  /usr/local/apache/conf/includes/post_virtualhost_global.conf
Add SWF extension to  "Don't compress images"
Here is my example:

<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
<IfModule mod_setenvif.c>
# Netscape 4.x has some problems…
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won’t work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don’t compress images
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png|swf)$ no-gzip dont-vary
</IfModule>
<IfModule mod_headers.c>
# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
</IfModule>

Exit from editor, save and restart httpd.
/etc/init.d/httpd restart
Refresh your website, it's should be ok.
eNj0y!

Tuesday, May 15, 2012

mySQL dump - Import/Export database

How to import sql dump file to mySQL database?

Connect to the server ssh and run following commands.
Import DB:

cd ~
mysql -u database_user -p yourdatabase_db < restore_db.sql
type your mysql password.
Check if all tables exist:
mysql -u database_user -p
type your mysql password again.
show databases;
connect yourdatabase_db
show tables;
Check if all tables exist.

Export DB:
cd ~
mysqldump -u database_user  -p yourdatabase_db > filename.sql
type your mysql password.
ls -l
check if filename.sql exist.




Installation of ConfigServer Security (csf) - cPanel

Installation and configuration of ConfigServer Security(csf & lfd) - for cPanel

csf installation:

1) Login to WHM and navigate to EasyApache.
2) For perfect installation and working of CSF and your websites, you will need to enable next modules and extensions before starting install it.

Must be enabled:

Ident
Imagemap
Mime Magic
Bz2
Curl
Curlwrappers
Exif
GD
Magic Quotes
Mbregex
Mbstring
Mcrypt
Mysql
PDO
TTF
Tidy
XSL
Zip

For finish installation choose "Save and build" and wait few minutes until you get complete message.
Next steps:
Connect to your server via ssh and run next commands to install csf:

cd ~
tar -xzf csf.tgz
cd csf
sh install.sh

That's all, csf is installed successfully . To configure csf and lfd go to /etc/csf/ directory and open with your favorite editor next files:
cd /etc/csf
vi csf.conf
White list: csf.allow
Black list:  csf.deny
To add a specific IP to black list edit csf.deny and add IP Address.
For example:
vi csf.deny
167.XXX.XX.XXX # (too many wrong authentication)
All logs of csf located in /var/logs/lfd.log
To start/stop/restart csf, run from command line /etc/init.d/csf start
Also you can configure it through WHM -> Plugins -> ConfigServer Security & Firewall.
eNj0y!




Wednesday, May 9, 2012

Import database error. phpMyAdmin.

"Got a packet bigger than 'max_allowed_packet' bytes"


To resolve this issue, you need to add or edit line in my.cnf file.

cd /etc
vi my.cnf
under [mysqld] add following:

max_allowed_packet=5M

Save and quit from your editor and restart mysql.
/etc/init.d/mysql restart
Try to import db again.

Tuesday, May 8, 2012

How to enable error printing in magento?


"There has been an error processing your request

Exception printing is disabled by default for security reasons.

Error log record number: XXXXXXXXXXXX"


Solution:

Via file manager:
First of all, go to your root directory.
public_html/errors
Copy local.xml.sample to local.xml

Via SSH:
cd /home/webUser/public_html/errors
cp local.xml.sample local.xml

Refresh your website.