Wednesday, April 23, 2008

Blackberry Pearl 8100 + Bluetooth + NextG Telstra

Ever wondering how to use your Telstra NextG Blackberry Pearl on your laptop as a wireless modem? read on...

first, turn on the bluetooth on your blackberry and make is discoverable
turn on the bluetooth on your laptop and search for your blackberry

set your laptop connection on your blackberry as a trust connection

your laptop should detect the blackberry as a modem

go to control panel, go to phones and modem, find the new modem of your blackberry
go to its properties, click on advanced and put the following:

+CGDCONT=1,"IP","telstra.internet"

if you are using Telstra use the APN of Telstra which is: telstra.internet, otherwise, you need to find out from your service provider

create a dial up connection, use that modem - no username and password needed
the number to dial is: *99#

dial and connect!

Monday, April 07, 2008

Find the users' OU from Active Directory

If you need to find the Active Directory user accounts' OU, run the following script:

Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")

objConnection.Provider = "ADsDSOObject"objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection


objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

REM get the filename
If WSCript.Arguments.Count <> 1 Then
WScript.Echo "Text file contains user accounts must be supplied"
WScript.Quit 0
End If

dim filenamefilename = WScript.Arguments.Item(0)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objDictionary = CreateObject("Scripting.Dictionary")

Const ForReading = 1

Set objFile = objFSO.OpenTextFile (filename, ForReading)

i = 0
Do Until objFile.AtEndOfStream
strNextLine = objFile.Readline
If strNextLine <> "" Then
getOu strNextLine
End If

i = i + 1
Loop

objFile.Close

REM Sub to get username OU


Sub getOu( username )
objCommand.CommandText = "SELECT distinguishedName FROM 'LDAP://dc=domain,dc=com'" & "WHERE objectCategory='user' " & "AND sAMAccountName='" & username & "'"

Set objRecordSet = objCommand.Execute

If objRecordSet.EOF Then
WScript.Echo username & " does not exist "
Else
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
strDN = objRecordSet.Fields("distinguishedName").Value
arrPath = Split(strDN, ",")
dim uOu

for each ou in arrPath
if Left( ou, 3 ) = "OU=" Then
if uOu = "" Then
uOu = ou
else

uOu = uOu & "," & ou
end if

end if
Next


uOu = username & " : " & uOu
Wscript.Echo uOu

objRecordSet.MoveNext
Loop
End If
End Sub

copy the above code to .vbs file (e.g. getOu.vbs). You also need to change the domain name from the LDAP query to your domain name in the code above.

Next, you need to create a text file just having a username per-line, e.g. users.txt

bgates
dduck

Next, run the the following:

cscript getOu.vbs c:\users.txt

Friday, April 04, 2008

View SQL 2005 Table Fragmentation

To view how fragmented your table is, run the following query:

USE dbname
GO
SELECT CAST(DB_NAME(DATABASE_ID) AS VARCHAR(20)) AS 'DatabaseName',
CAST(OBJECT_NAME([OBJECT_ID]) AS VARCHAR(20)) AS 'TableName',
INDEX_ID,
CAST(INDEX_TYPE_DESC AS VARCHAR(20)) AS INDEX_TYPE_DESC,
AVG_FRAGMENTATION_IN_PERCENT
FROM SYS.DM_DB_INDEX_PHYSICAL_STATS (DB_ID('dbname'),OBJECT_ID('dbo.tablename'),NULL,NULL,NULL );
GO