If you are doing LDAP integration work with Active Directory and you want to update a user's password via an LDIF script you need to specify the password attribute in a very specific way.
The sequence of steps is this:
Surround the password with speech marks, "like this"
Covert to bytes using the Unicode character encoding - a two byte code page which pads the low ASCII characters with 0
Encode using Base 64
So something like password becomes IgBzAGUAYwByAGUAdAAiAA==
This all sounds well and good, here's a code sample:
PublicFunction FormatPassword(ByVal password AsString) AsStringIf password IsNothingThenThrowNew ArgumentNullException("password", "password cannot be nothing")
' enclose in speech marks
password = String.Format("""{0}""", password)
' convert to bytes with unicode encodingDim bytes() AsByte = Encoding.Unicode.GetBytes(password)
' convert to base 64Dim base64 AsString = Convert.ToBase64String(bytes)
Return base64
End Function
The double-colon is required on the unicodePwd attribute as it identifies that the data which follows is Base64 encoded.
To import this into Active Directory, you will need to use the ldifde command line too.
Password Policy
You must make sure your passwords meet the strength and history requirements of the systems password policy, otherwise you will receive the following error message:
The server side error is: 0x52d Unable to update the password.
The value provided for the new password does not meet the length, complexity, or history requirements of the domain.
The extended server error is: 0000052D: SvcErr: DSID-031A11E5, problem 5003 (WILL_NOT_PERFORM), data 0
ldifde Secure Connection
When settings passwords, Active Directory insists you use a secure connection otherwise you will get an Unwilling To Perform error like this:
Add error on entry starting on line 1: Unwilling To Perform
The server side error is: 0x1f A device attached to the system is not functioning.
The extended server error is:
0000001F: SvcErr: DSID-031A11E5, problem 5003 (WILL_NOT_PERFORM), data 0
To specify a secure connection to LDAP, use ldifde like this:
ldifde -i -f -h -v myscript.ldf
I hope this helps!
0 comments,
Software, Thursday, October 22, 2009 20:34
A number of times I have found myself unable to access a file because some other process is writing to it.
Usually lock files which are used to prevent multiple instances of the same program from running at the same time, or to guard against multiple operations running at the same time that would interfere with each other.
The Linux command which comes to the rescue is called lsof which I guess is short for "list of open files"
It can be used in several different ways:
List All Open Files
lsof
This will list all the God damn files open on your system. There will be lots of other interesting things listed which are not files, things like pipes and network sockets. This is because on Linux, everything is abstracted to a file, even the keyboard.
The output from lsof can be piped to grep to search for bits of file names.
lsof | grep pony
This will perform a very crude search for any file name, path or process with anything to do with 'pony'
List All Open Files for a Given Process (by PID)
For example:
lsof -p 12345
Lists all file handles currently held by process 12345
lsof headings
By default, the lsof output looks like this (without headings)
Once you start this instance, you can browse to its public DNS name to see the XSP test sites.
This instance is intended to serve web applications or run console based applications or services; it does not have any kind of graphical interface.
Ingredients
This instance was made from:
Amazon’s Fedora 8 base image (ami-5647a33f v1.08)
Latest updates via yum
Apache 2.2.9 installed via yum
Apache and mod_mono are configured to serve the XSP 'test' files from the web site's root in /etc/httpd/conf/httpd.conf (at the bottom)
The following have been compiled and installed from the Mono 2.2 stable sources with the --prefix=/usr
mono-2.2
mono-basic-2.2
mod_mono-2.2
libgdiplus-2.2
xsp-2.2
Sample Projects
The sample ASP.Net files for 1.0 and 2.0 are installed at this root:
/usr/lib/xsp/test
The Apache config (/etc/httpd/conf/httpd.conf) file has been configured to serve an ASP.Net application from this location.
You can edit the Apache configuration file using vim. Use Ctrl-D in vim to page-scroll down.
vim /etc/httpd/conf/httpd.conf
# Set mono as the handler
SetHandler mono
# Configure a 'root' web application to run from root
MonoApplications root "/:/usr/lib/xsp/test"
MonoServerPath root /usr/bin/mod-mono-server2
<Location />
MonoSetServerAlias root
</Location>
Configuring your own ASP.Net applications
To serve your own ASP.Net applications from this instance, you need to store the files somewhere, for example, /mnt/MyApp, then modify the MonoApplications directive at the bottom of the Apache configuration file.
MonoApplications root "/:/mnt/MyApp"
Good luck and happy Mono developing!
Links
Mono AMI: documentation at Amazon community directory
From time to time, my web host changes some aspect of the server that this weblog is hosted on. The code that runs this site is written in classic ASP which means it is hosted on IIS. Recently another configuration change took place, presumably one of Microsoft's many hot fixes or an upgrade to a new version of Windows or IIS.
The following error started to appear tagged onto the bottom of every web page:
msxml3.dll error '80004001'
Not implemented
Behind the scenes, this site use XML and XSL to separate the site's data from its layout, in the middle somewhere is a line of code which performs an XSLT transformation on the XML DOM into the HTML output which gets squirted out into the response.
' method to transform the response (with errors)publicsub TransformToResponse_Old(xml, xsl)
xml.transformNodeToObject xsl, Response
end sub
Somewhere in the depths of ASP or IIS, a change has occurred which has dropped the IStream support of the classic ASP response object (I presume looking at the symptoms).
The fix introduces an intermediate stream to receive the XSLT transformation, and then send that to the response. This method also sets the response code page to be UTF8, which this site uses.
' method to transform the response (without errors)publicsub TransformToResponse_New(xml, xsl)
' By Tim Hastings, www.nonhostile.com' prepare stream to receive transformationdim outputStream
Set outputStream = Server.CreateObject("ADODB.Stream")
outputStream.Open
outputStream.Charset = "UTF-8"
outputStream.Type = 1 ' adTypeBinary' transform and output to stream
xml.transformNodeToObject xsl, outputStream
' set character-set
Response.CharSet = "UTF-8"
Response.ContentType = "text/html"
Session.CodePage = 65001
' rewind the stream and send to response
outputStream.Position = 0
Response.BinaryWrite outputStream.Read()
' finished with the stream
outputStream.Close
set outputStream = Nothingendsub
On Monday, Mono 2.0 was released by the Mono Development team. This release has been in-progress for a couple of years and is a major step forward in the mission to run .Net on Linux and other platforms. If you check out the release notes you can see there's a bus load of new features supported; including Linq!
To make it as easy to use Mono 2.0 in Amazon EC2 cloud I have built a new version of the image I created with Mono 1.9.1 a couple of months ago.
Once you start this instance, you can browse to its public DNS name to see the XSP test sites.
This instance is intended to serve web applications or run console based applications or services; it does not have any kind of graphics interface.
Ingredients
This instance was made from:
Amazon’s Fedora 8 base image (ami-2b5fba42 v1.07)
Latest updates via yum
Apache 2.2.6 installed via yum
Apache and mod_mono are configured to serve the XSP 'test' files from the web site's root in /etc/httpd/conf/httpd.conf (at the bottom)
The following have been compiled and installed from the Mono 2.0 stable sources with the --prefix=/usr
mono-2.0
mono-basic-2.0
mod_mono-2.0
libgdiplus-2.0
xsp-2.0
Sample Projects
The sample ASP.Net files for 1.0 and 2.0 are installed at this root:
/usr/lib/xsp/test
The Apache config (/etc/httpd/conf/httpd.conf) file has been configured to serve an ASP.Net application from this location.
You can edit the Apache configuration file using vim. Use Ctrl-D in vim to page-scroll down.
vim /etc/httpd/conf/httpd.conf
# Set mono as the handler
SetHandler mono
# Configure a 'root' web application to run from root
MonoApplications root "/:/usr/lib/xsp/test"
MonoServerPath root /usr/bin/mod-mono-server2
<Location />
MonoSetServerAlias root
</Location>
Configuring your own ASP.Net applications
To serve your own ASP.Net applications from this instance, you need to store the files somewhere, for example, /mnt/MyApp, then modify the MonoApplications directive at the bottom of the Apache configuration file.
MonoApplications root "/:/mnt/MyApp"
Good luck and happy Mono developing!
Links
Mono AMI: documentation at Amazon community directory
The article discusses how to setup MySQL Replication between two Amazon EC2 instances.
It walks you though setting up replication for an empty database server. Adding a slave to a server already full of data is a different article.
It is assumed that you already know the basics of starting EC2 instances, connecting to them via SSH and editing files in Linux using vi/vim etc.
For this tutorial, I am using the Amazon built machine image ami-2b5fba42 which is Fedora 8 base image.
Overview
In this tutorial, we will:
Launch two EC2 instances, a Master and a Slave
Install MySQL Server and tools onto each machine (must be the same version of MySQL on both)
Configure MySQL on each so that each has a unique server ID and keeps its data in an EC2 friendly place
Create a user on the master for replication and configure the slave to use it.
Synchronize the master/slave replication logs
Test it all works
Configuring the MySQL Master (shown in blue)
The steps for configuring the master are as follows:
Launch an EC2 instance using your favourite method (I like the ElasticFox Firefox extension)
Install MySQL Server and Client Tools (via Yum)
Edit /etc/my.cnf to alter the data folder and edit replication settings
Configure MySQL to run at boot (in case we restart the instance)
Start MySQL and configure to run at boot
Create a MySQL user for replication
First, launch an instance of the Fedora machine, and connect using SSH.
This gives us a base Fedora instance.
Next, install MySQL and configure it to start when the machine boots (in case we decide to restart it)
Install MySQL Server and tools:
yum install -y mysql mysql-server
Rename the old config file (if you're interested in keeping it) and edit the /etc/my.cnf:
mv /etc/my.cnf /etc/my.cnf.old
vi /etc/my.cnf
To look something like this:
[mysqld]
# replication settings for MASTER
server-id = 1
# data folder
datadir = /mnt/mysql
# switch on binary logging (required for replication)
log-bin = mysql-bin
# system stuff
user = mysql
socket = /var/lib/mysql/mysql.sock
[mysqld_safe]
log-error = /var/log/mysqld.log
pid-file = /var/run/mysqld/mysqld.pid
Now we can configure MySQL to start at boot, start it now and connect.
chkconfig --level 2345 mysqld on
service mysqld start
mysql
Now we can create a replication user account:
GRANT REPLICATION SLAVE ON *.* TO 'ReplicationUser' IDENTIFIED BY 'ReplicationPassword';
FLUSH PRIVILEGES;
We're done. Next, the slave...
Configuring the MySQL Slave (shown in green)
This is an almost identical sequence of steps, with a couple of minor differences.
Start another Amazon instance in the same availability zone (if you want speed and no bandwidth cost) or in a separate zone if you are more concerned about availability.
Install MySQL Server and Client Tools (via Yum)
Edit /etc/my.cnf to alter the data folder and edit replication settings
Configure MySQL to run at boot (in case we restart the instance)
Start MySQL and configure to run at boot
Tell the MySQL Slave who/where the Master is (using internal DNS name)
Start replication on the slave
Once the slave instance is running, connect using SSH and install MySQL and tools (just like the master):
yum install -y mysql mysql-server
Rename the old config file (if you're so inclined) and edit the /etc/my.cnf:
mv /etc/my.cnf /etc/my.cnf.old
vi /etc/my.cnf
To look like this:
[mysqld]
# replication settings for SLAVE
server-id = 2
# data folder
datadir = /mnt/mysql
# switch on binary logging (not essential but handy if you want to replicate from this slave in the future)
log-bin = mysql-bin
# system stuff
user = mysql
socket = /var/lib/mysql/mysql.sock
[mysqld_safe]
log-error = /var/log/mysqld.log
pid-file = /var/run/mysqld/mysqld.pid
Now we can configure MySQL to start at boot, start the service going and connect:
chkconfig --level 2345 mysqld on
service mysqld start
mysql
On the Master, we need to determine the binary log's starting position. This is the byte offset that our Slave should start reading from. On the master, type the following:
mysql> SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000003 | 319 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
Next, we want to connect the SLAVE to the MASTER. For this, we need the replication user details we created earlier and the internal (or private) DNS name for the MASTER, this should be available from ec2-dim or the ElasticFox instances list. We also need the file and position we get from the master in the step above. This is done with the MySQL CHANGE MASTER command:
CHANGE MASTER TO
MASTER_HOST='domU-11-22-33-44-55-66.compute-1.internal',
MASTER_USER='ReplicationUser',
MASTER_PASSWORD='ReplicationPassword',
MASTER_LOG_FILE='mysql-bin.000003',
MASTER_LOG_POS=319;
We can now start the slave's replication process:
START SLAVE;
Testing To See If Replication Is Working
Now replication is working, we can issue commands against the Master, and check to see if the Slave replicates the result.
To do this, use two terminals side by side, one connected to the Master and one to the Slave.
On the Slave, we can now verify if the changes made to Master have been replicated:
mysql> SELECT * FROM HelloWorld.Message;
+-------------+
| Content |
+-------------+
| Howdy slave |
+-------------+
1 row in set (0.00 sec)
Congratulations! You have a working replication.
Summary
There are a number of things you can use your slave for:
Taking backups without locking the Master: If you cannot afford the downtime on your Master to take a backup (backups must lock tables/databases for consistency) you can use STOP SLAVE to pause replication while you take a backup from the Slave. Resuming replication will pickup where it left off. This prevents the master from slowing down or having to lock tables while a consistent backup is taken.
As part of a scale out strategy: You can modify your application to read data from one of a number of available slaves. This is suitable for read intensive applications with slow-changing data.
As a replication master: You can daisy-chain slaves off other slaves in either a long bus configuration or in a tree style hierarchy. Just because you can seems to be a good enough reason to me.
Run tests against like live data: If you break the replication link, you have a complete copy of your live databases to test your latest version against.
As a stunt-double Should disaster strike, and something bad happen to your master, you can change you application to use the Slave instead. If you enabled binary logging on the slave, then you are already in a position to attach new slaves to that and promote it to the new master. How easily your application can switch over to the new master is a design issue you must consider when encountering problems connecting to the master.
Here's another round-up of quotes, wisdom and snippets...
On succeeding
Whether you think you can or think you can't - you are right. [Henry Ford]
Anything worth having is worth fighting for.
Your most unhappy customers are your greatest source of learning. [Bill Gates]
If you’re trying to go south and you find yourself walking north, it’s always best to turn around. “We’ve walked this far already” isn’t a good enough reason to continue heading in that direction.
Around the time of Caesar, there was a European tribe that, when the assembly horn blew, always killed the last warrior to reach his assigned place, and no one enjoyed fighting this tribe.
My wife would rather have a ticket for one fur coat, than a ticket that gave her two or nothing. [Warren Buffet]
Son, you can do whatever you set your mind to. There's no shame in doing any job, the best you can hope for is that you enjoy it.
Defender's dilema: The guard must keep watch continuously, while the prisoner only needs to escape once.
Fall seven times, stand up eight. [Japanese proverb]
Let a hundred flowers blossom. [Chairman Mao]
Everyone chooses more or less what kind of events will happen to them by their conscious patterns of blocking and yielding.
Optimism makes you plan for success, pessimism makes you plan for failure. [Tim Hastings]
On the creative process
The first draft of anything is shit. [Hemingway]
Easy reading is damn hard writing. [Hawthorne]
No one has to see your failures unless you add vanity to folly and exhibit them. [Robert McKee]
The key to great writing is to leave out the boring bits that people skip. [Elmore Leonard]
On getting things done
A good plan, violently executed now, is better than a perfect plan next week.
Only put off until tomorrow what you are willing to die having left undone.
Worry often gives a small things a big shadow. [Swedish proverb]
Nothing of value comes easy.
On economics
Markets can remain irrational longer than you can remain solvent. [John Maynard Keynes]
If you owe the bank $100 that's your problem. If you owe the bank $100 million, that's the bank's problem. [JP Getty]
It is generally agreed that casinos should, in the public interest, be inaccessible and expensive. And perhaps the same is true of Stock Exchanges. [John Maynard Keynes]
OCTOBER: This is one of the peculiarly dangerous months to speculate in stocks in. The others are July, January, September, April, November, May, March, June, December, August, and February. [Mark Twain]
Save a little money each month and at the end of the year you'll be surprised at how little you have. [Ernest Haskins]
The safe way to double your money is to fold it over once and put it in your pocket. [Frank Hubbard]
On technology
Any sufficiently advanced technology is indistinguishable from magic. [Arthur C. Clarke]
It's a poor sort of memory that only works backwards. [White Queen, Through the Looking-Glass]
On software development
You can be Date Driven or Feature Driven but not both.
Normalize until it hurts, denormalize until it works.
Good judgement comes from experience, and experience comes from bad judgement.
Premature optimization is the root of all evil. [Knuth] ...but... Belated pessimization is the leaf of no good.
[Lattanzi]
Tesler's Law of Conservation of Complexity: You cannot reduce the complexity of a given task beyond a certain point. Once you've reached that point, you can only shift the burden around. [Larry Tesler]
Jakob’s Law of the Internet User Experience: Users spend most of their time on other sites. This means that users prefer your site to work the same way as all the other sites they already know.
On everything else
Everything you will ever need to know about medicine: Air goes in and out. Blood goes round and round. Oxygen is good. [from What we learn from the dying]
Better to keep your mouth shut and appear a fool than to open it and remove all doubt [Mark Twain]
You should not be judged by your looks, but you will.
After a crap-tastic summer (weather wise) we were granted a brief reprieve from the rain, so quick get out in the sunshine!
So lets play a game called splash Daddy.
Then, the new sheriff walked in town...
Meanwhile, back at the ranch...
As you can clearly see here; Ryan's been a busy boy.
He's mastered standing up.
Got walking sorted.
Climbing down from the settee - done that.
And he can get several stairs up. Good lad!
Give or take a week or two ago it was the 10 year anniversary of the graduation of most of my uni mates. A plan was formulated to have a reunion – what a good idea. During my time in Reading I made some really great friends and it was an absolute delight to regroup and revisit our university and retrace some of our steps. We managed to get all six of the Radstock Road house mates from 1996-97 for the weekend, plus Tom (a honorary house mate). Simon and Gary didn't make the main outing, by Simon caught up with Rob, Lox and John on the Sunday afternoon.
I cannot think of a more fitting tribute to my university friends than to plagiarise some of their photographs, and it gives me great pleasure to so. So here are some photos taken from our reunion weekend, intermingled with some others.
On Saturday, we headed onto the Whiteknights campus and gave the Cybernetics and Computer Science department a visit. Here we can clearly see the three computer scientists outside their department. It is humbling to see the origins of three industry titans. We can also see Lorenzo coveting a girly-frame bike (his was stolen from this spot). We then walked from campus to our old house passing Child's Hall on the way stopping to salute the spot where we had been collectively dis'sed years earlier (Jon and Rob's body language says it all).
Covering old ground in good time, we quickly passed famous landmarks such as Cemetery Junction and Mr Cod. Allowing us to negotiate London Road and return to our old homestead of Radstock Road. Oddly, very little had changed, in fact, our old fridge was outside in our house's front garden.
Here's a mixture of old and new photos from our neighbourhood.
After the nostalgia, we continued our walk into town where we visited some more old favourites (The Purple Turtle, The George Hotel, The Hobgoblin), we also met up with Tom, and by sheer chance, bumped into Curt and Keith at the Hobgoblin who were friends from GARP – a setting where many of the Radstock house mates first met. I think John won his pound back on the human fruit-machine.
I think that a measure of great friendship is that after years of separation you can pick up where you left off. I had forgotten how much common ground I shared with these guys and how much history we had. I have not laughed as much as I did this weekend for a very long time. Good times!
What I found fascinating was to hear how each of our lives had developed since we parted. It was great to hear about new things, reassuring to see hairlines and waistlines, but also amazing that here are the same people I knew, but now in totally different contexts. Just as they all know me and know I've changed there are also constants; despite 10 years, some things have not changed...
This post is trumpeting the successful installation of Debian onto a Linksys NSLU2 Network Storage Link.
The unit is a Network Attached Storage (NAS) server which allows upto two USB hard drive or flash drive to be network accessible from anywhere. There are lots of different firmware replacements available developed by the open source community and these allow you to use the NSLU2 as a dedicated Linux box.
The NSLU2's specs are:
266Mhz ARM Intel XScale CPU
32MB SDRAM
8MB Flash
10/100 RJ-45 Ethernet port
2 USB 2.0 ports
5V DC power consumption (solar power?)
I used a 4GB USB flash drive as the boot disk which I needed to manually partition as the instructions say you need at least 256MB for swap partition, but the Guided Partitioning process made approximately 93MB for swap. Below is a record of my settings:
My partitions were configured as:
3.7GB – Primary partition, used for ext3, bootable, mounted as /
380MB – Logical partition, used for swap (lots more than the recommended 256MB)
Ryan has just celebrated his first birthday, congratulations sunshine!!
In the past few weeks, Ryan's crawling and walking has come along lots. He's now able to find his way into different rooms and we have to keep an eye on him. It's nice because he can please himself a little bit more and he gets frustrated a less.
Ryan's birthday party was relocated from our house to St. John's at the last minute on account of the heavy summer rain. The venue was brilliant. Unfortunately, we had to cancel the bouncy castle, and we got lots of kiddie toys to play with instead. Fortunately there was lots of room to run around which is all that really matters.
Abigail and Ryan have their breakfast, lunch and dinner at the dinner table which looks into the back garden where Leo the Rabbit runs around. Each meal is usually an eventful combination of ambitious mouthfuls, mini-floods, chatting, cool tricks and Abigail's tactical diversions.
I can't imaging the number of meals we've clocked up at this table already.
As you can clearly see in this video, Ryan's walking is very good and he's able to occupy himself in our cupboards for ages.
For anyone interested in experimenting with Mono on Amazon EC2 I have created a publicly available image which you can instantiate and play with. It can be used for both ASP.Net applications and console applications. The image does not have a GUI so this is not an appropriate platform to test applications with a GUI.
Getting Started
It is beyond the scope of this post to cover the basics of using Amazon EC2, there are already great tutorials on how to do this. Once your instance is up and running, you can take your browser to the public DNS name to play with the ASP.Net XSP sample pages. Most of the samples are implemented in C#. There is some chatter in the forums saying that some of the ASP.Net samples are a bit broken, most work, please feel free to fix any bugs and contribute back :-)
If you want to host you own web pages, you will need to modify the Apache config file and either modify the served directory (at the bottom of /etc/httpd/conf/httpd.conf) or alternatively, add new virtual directories or virtual hosts as explained in mod_mono's documentation
I would also strongly advise any .Net developers interested in Linux to knock up a quick "Hello World" console application in Visual Studio and the copy it across to Mono. You do not have to recompile for Mono, it just works™, the Mono boffins have created a binary compatible version of the CLR and you app doesn't know the different (unless it starts to get get nosey). The only difference is that .Net executables have to be launched with the Mono command line tool, like this:
Apache and mod_mono are configured to serve the XSP 'test' files from the web site's root in /etc/httpd/conf/httpd.conf (at the bottom)
History
As part of my What’s on my iPod? Facebook application I have been using Amazon EC2 to host the PHP front-end application and Mono to run the backend data processor which is a console application implemented in VB.Net (written in Visual Studio 2005).
On occasion, I have tried to get ASP.Net working, but never quite got it right, and never really had to. But, this evening I have had a break-through, so I thought I would share my progress with anyone interested.
Color Blue is not a valid color (I disagree)
I had made many failed attempts to get ASP.Net working on Apache with mod_mono and mod-mono-server but usually came unstuck with obscure errors when executing some pages. Depending on the test page, it would report: "Color Green is not a valid color" or "Input string was not in the correct format" errors thrown from System.Drawing.WebColorConverter
After much searching and experimenting, the problem was pinpointed to System.Drawing's dependency on libgdiplus.so, when this library is installed (via yum) it would install the library as "libgdiplus.so.0.0.0", and a symbolic link to it called "libgdiplus.so.0", but not create the "libgdiplus.so" symbolic link required by System.Drawing - which causes this fault.
If you are experiencing this problem, make sure that libgdiplus.so exists in /usr/lib, if it does not, you can create a symbolic link to it with: