Categories
Linux SQL Transact-SQL Windows

Using Transact SQL to get length of TEXT field [T-SQL]

To calculate the lenght of a TEXT field the LEN function used to calculate the length of VARCHAR fields won’t work.

You need to use the DATALENGTH T-SQL function:

SELECT DATALENGTH(myTextField) AS lengthOfMyTextField

Categories
Linux

Gutenberg Project – free audio files legally

 http://www.gutenberg.org/browse/categories/1

Categories
Linux

Free Search Engine Rankings Check

Search Engine Rankings – Instant, online reports of web site rankings in 8 top search engines and web directories, including Google, Yahoo! Search, Bing (MSN), AOL, AltaVista, AllTheWeb, Yahoo! Directory, and Open Directory (Dmoz).

Categories
Administration Exchange Server 2007 Exchange Shell Linux Windows

Exchange Server 2007: Bulk mailbox-enabling users using Exchange Shell

Bulk mailbox-enabling users using the Exchange console

In Exchange Server 2007 SP1, the Exchange console (EMC) allows you to create mailboxes for existing users. When selecting an existing user in the New Mailbox wizard, you can select multiple users by using the regular SHIFT-Click (to select a continuous list of users) and CTRL-click (to pick the users you want).

First we need to find the users without mailboxes. The get-user command will list all users. The RecipientType property of the user is either User or UserMailbox. As the name clearly suggests, those with UserMailbox as RecipientType are already mailbox-enabled – leaving those with RecipientType User.

You can enable all users with RecipientType User:

get-user | where-object{$_.RecipientType –eq “User”}

Yes, that may not be a great idea! So let’s filter these users. If these users reside in a particular Organizational Unit, we can restrict our search to that OU. In this case, we’ll look for users in the OU called “People”:

get-user –organizationalUnit people | where-object{$_.RecipientType –eq “User”}

Now we get a list of all users (who are not mailbox-enabled) from that OU. We can further restrict this list to all users who are members of a particular department. Since Sales is our favorite department, let’s pick Sales:

get-user –organizationalUnit people | where-object{$_.RecipientType –eq “User” -and $_.department –eq “Sales”}

Now we’ve got a smaller list of folks – those residing in the People OU belonging to Sales dept. and aren’t mailbox-enabled yet. Let’s go ahead and mailbox-enable these users:

get-user –organizationalUnit people | where-object {$_.RecipientType –eq “User” -and $_.department –eq “Sales”} | Enable-Mailbox –Database “EXCHANGE1Mailbox Database” | get-mailbox | select name,windowsemailaddress,database

The above command mailbox-enables these users and outputs a list of their names, default email address, and the mailbox Store on which their mailbox(es) reside.

Similarly, you can also use other user attributes of user accounts like city, state, country, etc. to selectively mailbox-enable users.

PowerShell / Exchange shell does to VBS scripts what scripting did to repetitive GUI tasks.

Categories
Dell Linux PowerShell Windows

Getting Dell Service Tag using PowerShell

Powershell’s get-wmiobject commandlet makes getting the Dell service tag or serial number for (some) other computer models easy.

Get-WmiObject win32_SystemEnclosure | select serialnumber

This worked for me successfully with Dell and SuperMicro, however it didn’t work on and HP computer I have. Haven’t tried it on IBM or others yet. . .

Categories
AD/LDAP Administration Exchange 2007 Linux Mailbox Microsoft Scripts SMTP Windows

HOW TO: Export all email addresses from a domain

AD Users & Computers UI lets you list the mail column for each object, which displays the default (SMTP) email address for objects. You can export the list from ADUC as csv/txt. However, any additional email addresses in the proxyAddresses attribute are not exported.

There’s no GUI to list/export all email addresses. Here’s a script to do that – ListEmailAddresses.vbs.

File: ListEmailAddresses.zip

What does it exactly do?
– Queries Active Directory for Contacts & Groups
– Lists their email addresses
– Queries Users
– Lists enabled users’ email addresses
– Lists disabled users’ email addresses separately
– Outputs to command line and also to a text file – c:proxyaddresses.txt
X.400 addresses are ignored

Categories
Administration CLI Command Line Exchange Server 2007 Exchange Shell Linux Windows Windows 2000 Windows 2003

Exchange 2007 HOW TO: Add Email Addresses To Public Folders

How do we add email addresses to Public Folders?

It should be pretty simple – If Get-Mailbox shows the emailaddresses property for a mailbox, and Set-Mailbox allows you to use the -EmailAddresses switch to add email addresses, one can’t be blamed for believing it’ll work the same way for Public Folders.

Objects other than Public Folders need to be mailbox or mail-enabled to be Exchange recipients, Public Folders do not (Yes, they are mail-enabled by default). To modify mail-related attributes of Public Folders, you use the Set-MailPublicFolder command.

To add additional email address to a (mail-enabled) Public Folder:

$PF = Get-MailPublicFolder “Sales”

$PF.EmailAddresses += “Sales-EMEA@domain.com”

$PF | Set-MailPublicFolder

The first line gets mail-related properties of Public Folder “Sales” in a variable called $PF. Next, we add the additional email address, without wiping out the existing ones. Finally, we commit the change using Set-MailPublicFolder.

If you simply use Set-MailPublicFolder “Sales” -EmailAddresses “Sales-EMEA@domain.com”, it will replace the existing values in the EmailAddresses property.

Another difference to note between how the Set-PublicFolder and Get-PublicFolder commands work, compared to Set-MailPublicFolder and Get-MailPublicFolder – the former takes a relative path of a Public Folder. For instance, to get the Sales PF if it’s in the root of the Public Folder tree, we would need to add a before the name:

Get-PublicFolder Sales

However, the Get/Set-MailPublicFolder commands work using the alias/display name of the PF. Why the difference? One way to look at it – when using Get/Set-PublicFolder, you’re working with the actual Public Folder. When using Get/Set-MailPublicFolder, you’re working with the Active Directory object created for that Public Folder (which holds mail-related attributes, making it possible for a Public Folder to be mail-enabled).

To change the primary email address of the Public Folder “Sales” from “Sales@domain.com” to the new address we just entered – “Sales-EMEA@domain.com”:

Set-MailPublicFolder “Sales” -EmailAddressPolicyEnabled $false -PrimarySmtpAddress “Sales-EMEA@domain.com”

As you may have already figured out, we exempted the Public Folder from getting EmailAddressPolicies applied. In Exchange Server 2003/2000, you could change the default email address of a recipient, without unchecking the checkbox. Result: A few minutes after you completed the change, Recipient Policies would apply and change the primary email address back.

Exchange Server 2007 doesn’t let you change the default email address without exempting the recipient from email address policies.

Categories
Grep Linux SSH

Linux / UNIX Find Out What Program / Service is Listening on a Specific TCP Port

How do I find out which service is listening on a specific port? How do I find out what program is listening on a specific TCP Port?

Under Linux and UNIX you can use any one of the following command to get listing on a specific TCP port:

  • lsof : list open files including ports.
  • netstat : The netstat command symbolically displays the contents of various network-related data and information.

lsof command example
Type the following command to see IPv4 port(s), enter:
# lsof -Pnl +M -i4

Type the following command to see IPv6 listing port(s), enter:
# lsof -Pnl +M -i6

Sample output:

COMMAND    PID     USER   FD   TYPE DEVICE SIZE NODE NAME
gweather- 6591 1000 17u IPv4 106812 TCP 192.168.1.100:57179->140.90.128.70:80 (ESTABLISHED)
firefox-b 6613 1000 29u IPv4 106268 TCP 127.0.0.1:60439->127.0.0.1:3128 (ESTABLISHED)
firefox-b 6613 1000 31u IPv4 106321 TCP 127.0.0.1:60440->127.0.0.1:3128 (ESTABLISHED)
firefox-b 6613 1000 44u IPv4 106325 TCP 127.0.0.1:60441->127.0.0.1:3128 (ESTABLISHED)
firefox-b 6613 1000 50u IPv4 106201 TCP 127.0.0.1:60437->127.0.0.1:3128 (ESTABLISHED)
deluge 6908 1000 8u IPv4 23179 TCP *:6881 (LISTEN)
deluge 6908 1000 30u IPv4 23185 UDP *:6881
deluge 6908 1000 45u IPv4 106740 TCP 192.168.1.100:50584->217.169.223.161:38406 (SYN_SENT)
deluge 6908 1000 57u IPv4 70529 TCP 192.168.1.100:57325->24.67.82.222:21250 (ESTABLISHED)
deluge 6908 1000 58u IPv4 106105 TCP 192.168.1.100:38073->24.16.233.1:48479 (ESTABLISHED)
..........
......
ssh 6917 1000 3u IPv4 23430 TCP 10.1.11.3:42658->10.10.29.66:22 (ESTABLISHED)

First column COMMAND – gives out information about program name. Please see output header for details. For example, gweather* command gets the weather report weather information from the U.S National Weather Service (NWS) servers (140.90.128.70), including the Interactive Weather Information Network (IWIN) and other weather services.
Where,

  1. -P : This option inhibits the conversion of port numbers to port names for network files. Inhibiting the conver-
    sion may make lsof run a little faster. It is also useful when port name lookup is not working properly.
  2. -n : This option inhibits the conversion of network numbers to host names for network files. Inhibiting conversion may make lsof run faster. It is also useful when host name lookup is not working properly.
  3. -l : This option inhibits the conversion of user ID numbers to login names. It is also useful when login name lookup is working improperly or slowly.
  4. +M : Enables the reporting of portmapper registrations for local TCP and UDP ports.
  5. -i4 : IPv4 listing only
  6. -i6 : IPv6 listing only

netstat command example

Type the command as follows:
# netstat -tulpn

OR
# netstat -npl

Output:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp 0 0 0.0.0.0:6881 0.0.0.0:* LISTEN 6908/python
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 5562/cupsd
tcp 0 0 127.0.0.1:3128 0.0.0.0:* LISTEN 6278/(squid)
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 5854/exim4
udp 0 0 0.0.0.0:32769 0.0.0.0:* 6278/(squid)
udp 0 0 0.0.0.0:3130 0.0.0.0:* 6278/(squid)
udp 0 0 0.0.0.0:68 0.0.0.0:* 4583/dhclient3
udp 0 0 0.0.0.0:6881 0.0.0.0:* 6908/python

Last column PID/Program name gives out information regarding program name and port.
Where,

  • -t : TCP port
  • -u : UDP port
  • -l : Show only listening sockets.
  • -p : Show the PID and name of the program to which each socket / port belongs
  • -n : No DNS lookup (speed up operation)

/etc/services file

/etc/services is a plain ASCII file providing a mapping between friendly textual names for internet services, and their underlying assigned port numbers and protocol types. Every networking program should look into this file to get the port number (and protocol) for its service. You can view this file with the help of cat or less command:
$ cat /etc/services
$ grep 110 /etc/services
$ less /etc/services

Categories
Blog Blogger.com Linux Windows

How to Change the Width of Blogger Blogs

Modifying the Width of Your Blogger Blog

Here is a quick step by step tutorial on how to change the width of your Blogger Blog.  It will show you how to change the standard template so that the width is the same as this blog. This basically entails 4 things. First you increase the width of the Outer Wrapper and then you increase the width of the Header and then the two columns inside the outer wrapper. This would be the Post column and then the Sidebar column. Lastly you increase the width of your Footer.

Full tutorial here.

Categories
Linux Security

Understanding the Linux /etc/shadow file

Can you explain /etc/shadow file used under Linux or UNIX?

/etc/shadow file stores actual password in encrypted format for user’s account with additional properties related to user password i.e. it stores secure user account information. All fields are separated by a colon (:) symbol. It contains one entry per line for each user listed in /etc/passwd file Generally, shadow file entry looks as follows (click to enlarge image):

/etc/shadow file fields


(Fig.01: /etc/shadow file fields)

  1. User name : It is your login name
  2. Password: It your encrypted password. The password should be minimum 6-8 characters long including special characters/digits
  3. Last password change (lastchanged): Days since Jan 1, 1970 that password was last changed
  4. Minimum: The minimum number of days required between password changes i.e. the number of days left before the user is allowed to change his/her password
  5. Maximum: The maximum number of days the password is valid (after that user is forced to change his/her password)
  6. Warn : The number of days before password is to expire that user is warned that his/her password must be changed
  7. Inactive : The number of days after password expires that account is disabled
  8. Expire : days since Jan 1, 1970 that account is disabled i.e. an absolute date specifying when the login may no longer be used

The last 6 fields provides password aging and account lockout features (you need to use chage command to setup password aging). According to man page of shadow – the password field must be filled. The encrypted password consists of 13 to 24 characters from the 64 character alphabet a through z, A through Z, 0 through 9, . and /. Optionally it can start with a “$” character. This means the encrypted password was generated using another (not DES) algorithm. For example if it starts with “$1$” it means the MD5-based algorithm was used.