Building Blox IT

Thoughts from the Building Blox Guys

Useful exim commands with frozen messages

To delete frozen messages from the queue:

exim -bpr | grep frozen | awk {’print $3′} | xargs exim -Mrm

Another useful command is the following one that reports how many frozen mails are in the queue:

exim -bpr | grep frozen | wc -l

And finally this command reports how many mails (frozen or not) are in the queue:

exim -bpc

update: since writing this I’ve discovered a wonderful cheat sheet on exim on the net : here

How to accept any SSL certificate when using a webrequest in .net

Have you ever received that error

The remote certificate is invalid according to the validation procedure

when attempting to communicate via https to a server?  When y0u browse the server in a browser, you probably get a warning which you can bypass, but how do you do it in code?

Simple, before you attempt to open the webrequest, set the ServerCertificateValidationCallback on the ServicePointManager to be handled by a custom function, which accepts your certificate. An example is shown below

ServicePointManager.ServerCertificateValidationCallback = New Net.Security.RemoteCertificateValidationCallback(AddressOf(ValidateCertificate) 

This sets up the initial callback to point at a function ValidateCertificate, the code for this is shown below

Private Function ValidateCertificate(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As Net.Security.SslPolicyErrors) As Boolean
        ‘Return True to force the certificate to be accepted, nb this accepts any certificate.
        Return True
    End Function

And yes, I know the example is in VB.NET, I’m being hampered in my current contract by using it!

Mounting a samba share on a linux box running Debian

Recently I had a need to transfer some files between servers in a remote location, the server I was dumping data onto exposes a samba share so I thought, I know I’ll just mount the share on the linux server I’ve remoted into, and copy the files.  The server I was remoted into had samba running, it’s a file server as well.  In order to get the file server set up for mounting I had to install a couple of tools:

sudo apt-get install smbclient smbfs

Installing the smbclient allows you to query the samba server and list all shares

smbclient -L //server

Ensure that smbfs is installed on your server otherwise the remote file system will be unmountable and you get everybodies favourite smb error

mount: wrong fs type, bad option, bad superblock on //server/path,
missing codepage or other error
In some cases useful info is found in syslog – try
dmesg | tail or so

And away you go, you can now mount the samba share and copy files with impunity!

sudo mount -t smbfs //server/path /mountpoint -o rw,username=username,password=password

SQL Server Management Studio 2008 Save Changes Requires Table Drop

Have you ever come across that lovely piece of functionality within SSMS 2008 where you go to edit the structure of a table and it pops up with the delightful message ‘Saving Changes is not permitted’.

 

PreventSave2_2 

There is of course a way around this, wander to the tools menu, Options, Designers, Tables and Database Designers and untick the option ‘Prevent saving changes that require table re-creation’.

dialog

 

Adding a Web Reference to a Class Library Project in Visual Studio

Ok, so we all know how to add a Web Reference into a Web Project in Visual Studio, but adding a Web Ref to a class library is a little different.  When you right click on the project file, you get the option to add a reference or to add a service reference, no option to add a web reference.  So, what we do is click on Add Service Reference.  Up pops the Service Reference Dialog…

Service Reference Dialog

Service Reference Dialog

Click the advanced button, this takes you to the next screen…

Advanced options

Advanced options

From here I’m sure you can work out what to do ;) Once you’ve added the first web reference into the project, the default option to add a web reference will exist on the context menu for the project.

  • Links

  • del.icio.us