Search Windows and Linux Networking

Friday, November 15, 2013

How to Search All Disabled User In Active Directory.

How to Search all Disabled User In Active Directory and export in to the Excel File using VBScript.


OR

 How to Search all Active/Enabled User In Active Directory and export in to the Excel File using VBScript


There are some time when you needed or your manager ask to provide all Disabled user Or currently all Active User from Active Directory in excel file and there are more than 100 Accounts in your Active Directory and you have to give all information in limited time frame. then best option is to use VbScript that search all disabled or All Active/Enabled users in Active Directory.

Following is the VBScript that Search for all Disabled Users in entire domain.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 Option Explicit
Dim objRootDSE,strDNSDomain,adoConnection,strQuery,adoRecordset,Field
Dim CN,FirstName,LastName,initials,Descrip,EmailAddr
Dim strFileName, ObjExcel, intRow

'Search all Disabled users in Active Directory and export them in to Excel file.


wscript.echo "Searching all disabled users in Active Directory please wait...."

'Open Excel file to Write the Data

Set ObjExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.WorkBooks.Add()
intRow = 1
       ObjExcel.Cells(intRow,1).Value = "CN"
       ObjExcel.Cells(intRow,2).Value = "FirstName"
       ObjExcel.Cells(intRow,3).Value = "initials"
       ObjExcel.Cells(intRow,4).Value = "LastName"
       ObjExcel.Cells(intRow,5).Value = "EmailAddr "

' Bind to Domain or OU

Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADSDSOObject"
adoConnection.Open "ADs Provider"
strQuery = "<LDAP://" & strDNSDomain & ">;(&(objectCategory=person)(objectClass=user));adspath;subtree"

'Define condition for search
Set adoRecordset = adoConnection.Execute(strQuery)

' Loop to search users through them...


Do While Not adoRecordset.EOF
     Set Field = GetObject(adoRecordset.Fields(0).Value)
     If Field.accountDisabled = TRUE Then
       'wscript.echo "Account " & Field.displayname & " is disabled"
       intRow = intRow + 1
       Cn = Field.CN
       FirstName = Field.GivenName
       LastName = Field.sn
       initials = Field.initials
       Descrip = Field.description
       EmailAddr = Field.mail

       'Wscript.echo "Users full Name is " & FirstName & " " & initials & " " & LastName & " and his Email ID is " & EmailAddr

       ' Write to Excel File
       ObjExcel.Cells(intRow,1).Value = CN
       ObjExcel.Cells(intRow,2).Value = FirstName
       ObjExcel.Cells(intRow,3).Value = initials
       ObjExcel.Cells(intRow,4).Value = LastName
       ObjExcel.Cells(intRow,5).Value = EmailAddr
     
      End If
 
adoRecordset.MoveNext

Loop
'If completed notify as it done.
wscript.echo "Done"

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++





You can also use this script to search all Active/Enabled user in entire domain by just modifying condition Field.accountDisabled = TRUE with Field.accountDisabled = FALSE

OR

You can also use this script to find all Active/Disalbed users by just modifying Bind base string (strQuery ) using Organization Unit. For example

strQuery = "<LDAP://OU=DisabledAccounts,DC=Example,DC=com>;(&(objectCategory=person)(objectClass=user));adspath;subtree"

I hope this will help you. :-)

Thursday, October 24, 2013

How to disabled IPv6 on Windows 2008 Server from registry

Step to permanently disabled IPv6 from Windows 2008 Server or windows 7.


If you do not required IPv6 on your windows 2008 Server system or windows 7 Desktop you can disabled it from registry.



To disabled IPv6 support go to:-

login in to the server/Desktop with user member of Administrator group and follow the step

 Start> run > and type regedit. Expand the path

Coputer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\TCPIV6\Parameters

Now Right Click the folder Parameters and Select New > DWORD(32-Bit) Value > Name the key as DisabledComponents
Now open the DisabledCompontents key and type ffffffff and click ok.<8 time " f " with lower case >

Final setting look like this:-



Now close the all application and restart your server/Desktop.


After reboot check IPv6 disappear from command result ipconfig /all