Using CSVDE to export computer accounts from AD

I was putting together some documentation and need an export of all computer accounts in Active Directory.


Export Computer Accounts – This will export the DN (distinguishedName, CommonName)
csvde -f output.csv -d “DC=Steve,DC=Schofield,DC=com” -r “(objectClass=computer)” -l cn -j c:

All objects in a specific OU.
csvde -f output.csv -d “OU=My EmailContacts,OU=EmailStff,DC=Steve,DC=Schofield,DC=com” -r “(objectClass=*)” -l mailNickName,cn -j c:


Hope this helps.


Steve

Relay Restrictions and SMTP service, IISOLE.dll reference

This is one of *those* posts I refer to from time to time.  There have been a few posts on http://Forums.iis.net regarding how to manage relay restrictions in SMTP service.   I’ve used the IISOLE.dll against an IIS 6 server with no issues.  I’ve not tested on IIS 7, so mileage may vary.  Make sure to install the IIS 6.0 compat modules and test on a non-production box.   If nothing else, download a trial version and create an instance using vmware, hyper-V or Virtual PC.  


http://forums.iis.net/p/1148477/1865759.aspx


On a side note for SMTP questions.   I’d recommend checking the SMTP / NNTP newsgroup host by Microsoft.   This is an active and targeted source of information for the SMTP service. 


http://tinyurl.com/c96eww


Hope this helps.

Cheers,


Steve

Day of .NET summary

Attending a local event such as Code Camp, Day of .NET or something similar can be a great way to keep up-to-date on technologies you don’t work with everyday.   These events are usually one day, free of charge and contain a lot of great information.  I attended our local version put on by Chris Woodruff.  I attended the Sharepoint session put on by Rick Kierner   My current role has me doing a lot of Sharepoint / WSS, among other technologies.  Mostly what I’m doing is infrastructure and administration, attending the Day of .NET event introduced me to the developer side.  Here are some links mentioned. 


http://www.heathersolomon.com/blog/articles/148.aspx


Rick Kierner
http://rickdoes.net


 


40 templates available from MS.


http://www.microsoft.com/sharepoint/templates.mspx


 


WSP Builder on codeplex
http://www.codeplex.com/wspbuilder


 


Looking for a place to start (Download the VPC)
www.Mssharepointdeveloper.com


 


Sharepoint dev wiki
http://www.sharepointdevwiki.com


 


Sharepoint logs
http://tinyurl.com/3ng88v


 


I was glad to see Sharepoint has rich logging capabilites, IISLogs (component I wrote) can handle and process logs to keep things under control.   Sharepoint has the ability to automatically clean up logs (which is great!).  However, if you want to keep a few weeks around and zip them up, IISLogs can do the trick.   IISLogsLite 2.0 can handle .log files.


 


Thanks again Chris, Bill Miller and speakers for putting on a great event.


 


Cheers,


 


Steve Schofield


Microsoft MVP – IIS

Cache profile links in MOSS

I was working in MOSS recently and couldn’t see the Caching links.   After I activated the Office SharePoint Server Publishing Infrastructure feature, the three Caching links didn’t show up.  I can access them directly.  Here are the links.


Output Caching
http://example.com/_Layouts/sitecachesettings.aspx


Object Caching
http://example.com/_Layouts/objectcachesettings.aspx


Caching Profiles
http://example.com/Cache%20Profiles/AllItems.aspx


Additional Resources


 


Caching in MOSS
http://technet.microsoft.com/en-us/library/cc298466.aspx


 


Output Caching and Cache Profiles
http://msdn.microsoft.com/en-us/library/aa661294.aspx


 


 

Response.write saves the day. Display the last X number of event log records using ASP.NET on a remote machine.

It’s been a while since I wrote an ASP.NET app, at least 5 years.  ?   I needed to query remote servers to get the last X numbers of Event log entries.   One snag I ran into was trying to use the DataGrid or GridView controls.  I kept getting “Index out of bounds” error when trying to write the Message (Description) part of an event log message.   I reverted to my ‘old Classic ASP’ days and used response.write.   I never did find a solution using the built-in controls.   For those who want to allow others to view event logs w/o granting local access, your application pool needs the appropriate permissions.  I setup the application pool to run as a user that can access event logs.  Hope this helps.  PS: I even have color coding! ?


Default.aspx


<html>


<body>
<form runat=server id=form1>


<table class=”style1″>
    <tr>
     <tr>
        <td class=”style2″>
            Number of records:</td>
        <td>
            <asp:DropDownList ID=”DropDownList3″ runat=”server” TabIndex=”0″>
                <asp:ListItem Selected=”True”>10</asp:ListItem>
                <asp:ListItem>25</asp:ListItem>
                <asp:ListItem>50</asp:ListItem>
            </asp:DropDownList>
        </td>
    </tr>  
        <td class=”style2″>
            Machine Name:</td>
        <td>
            <asp:DropDownList ID=”DropDownList2″ runat=”server” TabIndex=”0″>
            <asp:ListItem Selected=”True”>ServerX</asp:ListItem>
            <asp:ListItem>ServerY</asp:ListItem>
            <asp:ListItem>ServerZ</asp:ListItem>
            </asp:DropDownList>
        </td>
 </tr>
    <tr>
        <td class=”style2″>
            Event Log</td>
        <td>
            <asp:DropDownList ID=”DropDownList1″ runat=”server” TabIndex=”1″>
                <asp:ListItem Selected=”True”>Application</asp:ListItem>
                <asp:ListItem>Security</asp:ListItem>
                <asp:ListItem>System</asp:ListItem>
            </asp:DropDownList>
        </td>
    </tr>
</table>
 <br />
<br />
<br />
<br />
<asp:Button ID=”Button1″ runat=”server” Text=”Button” />
    <asp:GridView ID=”GridView1″ runat=”server” AutoGenerateColumns=”False”
        DataKeyNames=”TimeGenerated” EnableTheming=”False” EnableViewState=”False”
        PageIndex=”1″ PageSize=”11″>
        <Columns>
            <asp:BoundField DataField=”Message” />
            <asp:BoundField DataField=”TimeGenerated” HeaderText=”Daetime”
                SortExpression=”TimeGenerated” />
            <asp:BoundField DataField=”Source” HeaderText=”Source”
                SortExpression=”Source” />
            <asp:BoundField DataField=”EntryType” HeaderText=”EntryType”
                SortExpression=”EntryType” />
        </Columns>
    </asp:GridView>
<asp:DataGrid id=”LogGrid” runat=”server”
    BorderColor=”black”
    BorderWidth=”1″
    GridLines=”Both”
    CellPadding=”3″
    CellSpacing=”0″
    Font-Name=”Verdana”
    Font-Size=”8pt”
    HeaderStyle-BackColor=”#aaaadd”
    AutoGenerateColumns=”False”
 PageSize=”25″
 Font-Names=”Verdana”
 >
    <Columns>
      <asp:BoundColumn HeaderText=”TOF” DataField=”EntryType” />
      <asp:BoundColumn HeaderText=”Date/Time” DataField=”TimeGenerated”/>
      <asp:BoundColumn HeaderText=”Source” DataField=”Source”/>
      <asp:BoundColumn HeaderText=”Message” DataField=”Message”/>
    </Columns>


<HeaderStyle BackColor=”#AAAADD”></HeaderStyle>
</asp:DataGrid>


<br />
</form>


</body>


</html>


Default.aspx.vb


Partial Class _Default
    Inherits System.Web.UI.Page
       Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Page.IsPostBack = True Then
          Response.Write(DropDownList2.Text.ToString() & “<br>”)


            Dim aLog As New Diagnostics.EventLog
   dim z as integer = DropDownList3.Text
            aLog.MachineName = DropDownList2.Text
            aLog.Log = DropDownList1.Text


            ‘LogGrid.DataSource = aLog.Entries
            ‘LogGrid.DataBind()


            ‘GridView1.DataSource = aLog.Entries
   ‘GridView1.DataBind()
            Dim y As Integer = 0
            Response.Write(“<table border=2 cellpadding=2 width=’100%’>”)
            Response.Write(“<b><tr><td>Counter</td><td>TOF</td><td>TimeGenerated</td><td>Source</td><td>Message</td></tr></b>”)
            Dim item As Diagnostics.EventLogEntry
            For Each item In aLog.Entries
                y = y + 1
                If y = z Then
                    Exit For
                End If
                Response.Write(“<tr>”)
                Response.Write(“<td>” & y & “</td>”)
                Response.Write(“<td>” & aLog.Entries.Item(aLog.Entries.Count – y).EntryType.ToString() & “</td>”)
                Response.Write(“<td bgcolor=’#FFFF99′>” & aLog.Entries.Item(aLog.Entries.Count – y).TimeGenerated.ToString() & “</td>”)
                Response.Write(“<td>” & aLog.Entries.Item(aLog.Entries.Count – y).Source.ToString() & “</td>”)
                Response.Write(“<td bgcolor=’#FFFF99′>” & aLog.Entries.Item(aLog.Entries.Count – y).Message.ToString() & “</td>”)
                Response.Write(“</tr>”)
            Next
            Response.Write(“</table>”)
        End If
    End Sub
End Class


Here is the event log class reference on MSDN


http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx


Cheers,


Steve