PCBSD 8 on an IBM T40

Hello all,

I thought I would share my experiences of using PCBSD 8 on an IBM T40.  I am going to put the information in separate headings, and I am going to document who is responsible for the feature I am talking about by prefacing each line with the responsible party.  If it is a positive experience, the responsible party will be in Green.  If it is a negative experience the responsible party will be in Red.

I am probably going to reinstall and do all this over again with the “snapshot” version and look for any improvements and try to submit any bugs/suggestions to Kris and his team.

IBM T40 Hardware Specs

Intel Pentium M
ATI Radeon Mobility M7 LQ (Mobility Radeon 7500 (fdds)
Intel PRO/Wireless 2200BG
Realtek AC97 Audio
Intel 82801DB PRO/100 VE Network Connection
UltraATA/100 EIDE Controller
34 GB 5400 RPM drive

Installation of PCBSD

9:20 AM started boot process
9:25 AM Finished configuring and clicked “Install”
9:37 AM 47% finished
Sorry, I was pulled away for an hour so I don’t know how long hte install took. I did find an install log, but unfortunately it had no date stamps. I rebooted before I realized that the log file itself might have had a timestamp.

PCBSD: So I don’t know how long the install took but it felt too long. I wonder if there are some tricks that can be done to speed this up.  For example, the install could use an image. It could lay down the image, then extend the last partition to fill the drive, and then modify the key files after the image is laid down, add any packages not included in the image.

Boot options

PCBSD: Adding the “Run X in Vesa mode” as item 6 is pretty cool.
PCBSD: Adding the “Run the Display setup wizard” is nice, so you can try to use a different video card post setup.
PCBSD: Single user mode and other boot options normal to FreeBSD still exist.
PCBSD: Splash screen works (this is an x86 box)
PCBSD: The bootup takes too long, there should be some ways to speed it up.

FreeBSD: I like to have a shorter delay when booting. 10 seconds is too long for me. So I added this to /boot/loader.conf

# Boot Options
autoboot_delay=”3″

Post-install Setup

Update: So I reinstalled because I tried a PC-BSD 8-stable snapshot, but ran into a FreeBSD bug, so I returned to PCBSD 8 release.  On Reinstall, the ATI-3D-Enabled drivers worked, so I am editing this to say so.  I am not sure why they didn’t appear to work the first time.  Maybe because I had tried the Radeon settings first, I don’t know.

PCBSD: On first boot, there was a great interface for configuring Xorg.

PCBSD: This has a Radeon card, but there was no option for Radeon, just ATI or Radeonhd and neither worked really.

  • Tried Radeonhd drivers – both normal and 3D failed to launch Xorg.
  • Tried ATI drivers – both worked but I used the one that enabled 3D features.

Note: I found another solution that added 3D features I wanted. See the Xorg and KDE4 Features section.

Networking

FreeBSD: Wired networking worked using DHCP without me having to do anything.
FreeBSD: Unplugging the wired network and plugging into a different subnet does not automatically cause dhclient to run again.  So in order to get new IP settings, I had to run /etc/netstart as root.  It didn’t work the first time either, I had to run it again.
PCBSD/KDE4: I couldn’t easily find a network tool to configure WIFI. I finally found it under System Settings.
PCBSD/KDE4: Once I did find the Newtork Configuration tool, it was easy to use and I connected to my WPA2 secured wireless network using a D-Link DIR-615 router.  It worked very well and I downloaded a lot with no hiccups.

Sleep/Resume

FreeBSD/ACPI: Put machine to sleep. Worked fine.
FreeBSD/ACPI/moused:
Woke machine up. No mouse. Had to use Ctrl + Alt + F1 to get a command prompt and fix this by restarting the moused daemon.

Note: Added this line before exit 0 in the /etc/rc.resume. This doesn’t resolve the bug, but restarts the mouse so it works, which is a workaround, but workable none-the-less.

/etc/rc.d/moused/restart

PCBSD/FreeBSD: Closing the lid does not put the machine to sleep.

Note: I fixed this by added this line to the /etc/sysctl.conf

hw.acpi.lid_switch_state=S3

After making the above settings, you can run this command to change it in the current booted system so you don’t have to reboot.  But the setting in /etc/sysctl.conf is what makes this persist on reboot.

sysctl -w hw.acpi.lid_switch_state=S3

Random Usability Notes

PCBSD: Ports Console is easily confused with a regular console as Icon Text is not always looked at, I recommend a different icon and naming it Ports Jail. I created this for myself.

KDE4/PCBSD: The fonts were a little off for the four default icons vs the background…but this only seems to be an issue with dark backgrounds.
Shutdown and Reboot works as a regular user by default.
KDE4: After selecting Reboot or Shutdown, there is a hesitation before the shutdown/reboot popup, so I sometimes double click. I don’t like how the shutdown/reboot popup just disappears if a second click occurs with the mouse anywhere but on the shutdown/reboot popup.

Web Usability

Firefox/Flash/FreeBSD: YouTube – Went online and clicked on one of the first videos and it played.

Xorg & KDE4 Features

Update: Do to a reinstall, I noticed that choosing ATI 3D actually worked an enabled 3D features.  I will check on the settings below to see whey they set.
Even though I had a Radeon, only the ATI or ATI 3D drivers worked. The RadeonHd drivers did not work.  Probably because it is an old Radeon and not a new RadeonHd.

Note: I got the Radeon driver to work myself by using the xorg.conf from the ati3d settting and changing the “Device” section to use the settings below. I didn’t make these up on my own, I found them here: http://userweb.cs.utexas.edu/~walter/geek/linux-t40.html#video

Section "Device"
	Identifier	"ATI Radeon"
	Driver	"radeon"
	Option	"DynamicClocks" "on"
	Option	"AGPMode" "4"
	Option	"RenderAccel" "on"
	Option	"EnablePageFlip" "on"
	Option	"BIOSHotkeys" "on"
	BusID	"PCI:1:0:0"
EndSection

After doing this, I got much better settings as described below:

Xorg/KDE4: Konsole supports transparency when using ATI 3D.
Xorg/KDE4/3D: Moving the cursor to the top of the screen will do a cool screen where it shows your configured screen in a line from left to right (four by default though I always change to 3).
Xorg/KDE4/3D: Moving the cursor to the top right corner of the screen will do a cool screen where it shows your configured screens in a 3D object (cube or pyramid).

Ctrl + Alt + Backspace is disabled

Ctrl + Alt + F1 does display the terminal sessions and then:

Alt + F2, F3, F4, …, F8 will all take you to one of the open console terminal sessions.
Alt + F9 returns you to your Xorg seesion

KDE4/PCBSD: Alt + F1 does NOT open the start bar. Right-clicking on the Fireball and choosing Application Launcher settings shows no shortcut, so you can configure it if desired. When I install KDE4 the default is Alt + F1, not None, so I assume this is something PCBSD changed.

KDE4: After selecting Reboot or Shutdown, I don’t like how the reboot option or shutdown option just disappears if I click with the mouse on the desktop.

Software Installation

PCBSD: PBIs make installing software fairly easy.
PCBSD: There are not enough PBIs.
PCBSD: The size of PBIs are HUGE, which is by design, they include every library they need to run, but by design or not, they are huge.
PCBSD: I installed Firefox and Open Office and Pidgin post install because there are updated version to those on disk anyway.

KDE4/Firefox: Firefox prompts every single time I open it to be the default browser. Saying yes appears to do nothing. I manually went to KDE4’s System Settings and change the default application for the web browser to be /Programs/bin/firefox3.sh and this issue stopped.

PCBSD: K3b installed perfected first try.

External Media

PCBSD: K3b burnt a DVD (the latest PC-BSD snapshot) without having to perform any tweak, and for those who know how many tweaks are required when using just FreeBSD and not PC-BSD, you know why this is awesome.

Weirdnesses

Every boot when loading KDE4, the following error displays: The profile “” has been selected but it does not exist.

I plan to update this from time to time with my experiences, so this post is in no way final.


PC-BSD's Ports Console in a jail is cool, but I keep clicking when I want a normal console!

Hello all,

PC-BSD’s Ports Console in a jail is cool, but I keep clicking when I want a normal console!

So today, I got fed up and I drew a new Icon for it:

I then renamed it from Ports Console to Ports Jail.

I’ll never make this mistake again and I think I will suggest this idea on the PC-BSD forums.

Oops!

This didn’t exactly work as expected.  Sure, I never confuse the Icon on the desktop anymore, or in the KDE Menu, but now I have a different problem.  If I open the Jail first, then open the regular Konsole, the icon for the running Konsole and Jail apps in the task bar are both Jail icons. The same in reverse.  If I open Konsole, then open the Jail, the icons for the running Konsole and Jail apps in the task bar are both Konsole icons.

I can’t seem to make this work how I want.


Yep…I now install FreeBSD with PCBSD's Installer

So today, I need to install FreeBSD clean in a VM for testing. I thought, I am going to use the PCBSD 8 install disk because it is faster.

I am sorry, but I am a Sysinstall hater.

Thanks PC-BSD for the much faster installer.


How to open Windows Color and Appearance from the command line or a shortcut?

Ok, so I had a hard time finding Windows Color and Appearance in Windows 7.

It is pretty easy to get to the Windows Color and Appearance tool if you know where to go. The problem is that where to go is not obvious.  So here is where you go:

  1. Right-click on Desktop and choose Personalize.
  2. Click the Windows Color icon at the bottom of the screen.
  3. Clikc the Advanced appearance settings… link.

Besides the problem that it is not obvious where to go, there are also some computer some diseases that make this harder than it should be.

Disease #1 – Limited Clicking Ability Disorder or LCAD

People have what is called Limited Clicking Ability Disorder or LCAD.  In layman’s terms, click laziness. Yes, that means we want to get there in less clicks.

It is 4 clicks to get to the Windows Color and Appearance tool, assuming you know where you are going.  Otherwise, you have to click all over till you find it. Whether it is four or more, this is way too many clicks for someone who suffers from click laziness or LCAD.

The Cure

Create desktop shortcuts or shortcuts on your startbar.

Steps for creating a shortcut to the Windows Color and Appearance tool.

  1. Right-click on your desktop and choose New | Shortcut.
  2. In the Type and location of the item field type in:c:\windows\system32\desk.cpl ,5Note: Yes, there is a space between desk.cpl and the ,5.
  1. Click Next.
  2. In the Type a name for this shortcut field, enter this:Windows Color and Appearance
  3. Click Finish.

You now have a shortcut on your desktop which will all you to access Windows Color and Appearance in one click and cure your LCAD.

Note: If you want, you can right-click on the shortcut and choose properties and click the Change icon button and select a different icon if you want.

Disease #2 – Keyboard-to-Mouse Tropophobia

Tropophobia is the fear of moving and yes, Keyboard-to-Mouse Tropophobia is the fear of moving the hands from the keyboard to the mouse.

The Cure

Learn to access as many features as you can without using the mouse.

So how can you access the Windows Color and Appearance tool without going to mouse?  This one was not as easy as others, but the solution was found.

Steps for accessing the Windows Color and Appearance tool using only the keyboard

Do this:

  1. Press the Windows Key and the R key simultaneously.  This brings up the Start | Run tool.
  2. Type the following into the Open field:desk.cpl ,5Note: Yes, there is a space between desk.cpl and the ,5.
  3. Press Enter.

Sources:
This page got me started and my own knowledge got me an easier solution than what was posted here:
http://www.sevenforums.com/tutorials/59884-window-color-appearance-shortcut-create.html


Where to get a Select a Directory Dialog (or Folder Picker or Choose Directory Dialog) in WPF?

Ok, so to my dismay, Microsoft has not created a default widget for selecting a directory.

I searched and searched and searched. Found some here are there, but none were really what I wanted.

I finally found one I like, so I thought I would share it with you. Here is what I like about the one I found:

http://www.ookii.org/software/dialogs/


How to get your project's version dynamically in C#?

Ok, so I wanted to create a little Help | About page that looks like this.

MyProgram 1.0.0.5

Author: Jared Barneck

Contributors: John, Mike, Mark, Tom, Bill, Jane, Ryan, Josh

I don’t really want to have to remember to change the version in the help file with each release, so I wanted to get the version dynamically.

Turns out that you can get the version as a string with a single line of code:

String theVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

Once you have the version as a string, you can display it how you want.


Tutorial – Creating a StaticResource and Binding to it

The XAML allows you to provide what are called StaticResources. Such resources can be given to a Window or to certain controls.

For this tutorial, I assume you are in Visual Studio 2008. I assume that you already know how to create a new Project and choose WPF Application. All examples assume you have a new WPF Application.

So lets get started with three examples of binding to StaticResources.

Example 1 – Making a String a StaticResource and Binding to it

This example will demonstrate instantiating a String as a StaticResource and binding a TextBox to it.

Step 1 – Add the elements

  1. Add three TextBox elements into the default Grid control.
            <ListBox Margin="12,12,0,0" Name="listBox1" Height="100" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" />
            <ListBox Margin="138,12,20,0" Name="listBox2" Height="100" VerticalAlignment="Top" />
            <TextBox Margin="12,118,0,121" Name="textBox1" Width="120" IsReadOnly="True" HorizontalAlignment="Left" />
            <TextBox Margin="138,118,20,121" Name="textBox2" Width="120" IsReadOnly="True" HorizontalAlignment="Left" />
    
    

Step 2 – Add the static resources

  1. Add an xmlns reference to the System namespace. This is done by adding the xmlns:System line to as an attribute to the top Window element as shown:
    <Window x:Class="StaticResourceBinding.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:System="clr-namespace:System;assembly=mscorlib"
        Title="Window1" Height="300" Width="300">
    
  2. Create a Windows.Resources section in the XAML and add three Strings to it as StaticResources.
        <Window.Resources>
            <System:String x:Key="FirstName">Jared</System:String>
            <System:String x:Key="LastName">Barneck</System:String>
            <System:String x:Key="Alias">Rhyous</System:String>
        </Window.Resources>
    

Step 3 – Adding Binding to each TextBox element’s Text property

  1. Configure the three TextBox elements to bind to each String added as a StaticResource by adding a Text attribute.
            <TextBox Text="{StaticResource FirstName}" Height="23" Margin="51,25,107,0" Name="textBox1" VerticalAlignment="Top" />
            <TextBox Text="{StaticResource LastName}" Height="23" Margin="51,54,107,0" Name="textBox2" VerticalAlignment="Top" />
            <TextBox Text="{StaticResource Alias}" Height="23" Margin="51,83,107,0" Name="textBox3" VerticalAlignment="Top" />
    

The final XAML looks as follows. No changes were made to the code behind at all.

<Window x:Class="StaticResourceBinding.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:System="clr-namespace:System;assembly=mscorlib"
    Title="Window1" Height="300" Width="300">
    <Window.Resources>
        <System:String x:Key="FirstName">Jared</System:String>
        <System:String x:Key="LastName">Barneck</System:String>
        <System:String x:Key="Alias">Rhyous</System:String>
    </Window.Resources>
    <Grid>
        <TextBox Height="23" Margin="51,25,107,0" Name="textBox1" VerticalAlignment="Top" Text="{StaticResource FirstName}"/>
        <TextBox Height="23" Margin="51,54,107,0" Name="textBox2" VerticalAlignment="Top" Text="{StaticResource LastName}"/>
        <TextBox Height="23" Margin="51,83,107,0" Name="textBox3" VerticalAlignment="Top" Text="{StaticResource Alias}"/>
    </Grid>
</Window>

Example 2 – Declaring an array as a StaticResource and Binding a ListBox to it

This example will demonstrate instantiating arrays as StaticResources and binding a ListBox to the arrays.

To show an example of building onto existing or previous learned knowledge, we are going to also implement binding each TextBox's Text properties to the ListBox's SelectedItem property.

Step 1 – Add the elements

  1. Add two ListBox and two TextBox elements into the default Grid control.
            <ListBox Margin="12,12,0,0" Name="listBox1" Height="100" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" />
            <ListBox Margin="138,12,20,0" Name="listBox2" Height="100" VerticalAlignment="Top" />
            <TextBox Margin="12,118,0,121" Name="textBox1" Width="120" IsReadOnly="True" HorizontalAlignment="Left" />
            <TextBox Margin="138,118,20,121" Name="textBox2" Width="120" IsReadOnly="True" HorizontalAlignment="Left" />
    

Step 2 – Add the static resources

  1. Add an xmlns reference to the System namespace. This is done by adding the xmlns:System line to as an attribute to the top Window element as shown:
    <Window x:Class="StaticResourceBinding.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:System="clr-namespace:System;assembly=mscorlib"
        Title="Window1" Height="300" Width="300">
    
  2. Create a Windows.Resources section in the XAML and add two arrays as StaticResources: one an array of strings, and one an array of integers.
        <Window.Resources>
            <x:Array x:Key="StringList" Type="System:String">
                <System:String>Line 1</System:String>
                <System:String>Line 2</System:String>
                <System:String>Line 3</System:String>
                <System:String>Line 4</System:String>
            </x:Array>
            <x:Array x:Key="IntArray" Type="System:Int32">
                <System:Int32>100</System:Int32>
                <System:Int32>200</System:Int32>
                <System:Int32>300</System:Int32>
                <System:Int32>400</System:Int32>
            </x:Array>
        </Window.Resources>
    

Step 3 – Adding Binding

  1. Configure one ListBox's Text property to bind to the String array and the other ListBox's Text property to bind to the Int32 array.
            <ListBox ItemsSource="{StaticResource StringList}" Margin="12,12,0,0" Name="listBox1" Height="100" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" />
            <ListBox ItemsSource="{StaticResource IntArray}" Margin="138,12,20,0" Name="listBox2" Height="100" VerticalAlignment="Top" />
    
  2. We will also add binding to show you how you can combine binding to StaticResources and binding to another element’s property.Bind one TextBox to the listBox1.SelectedItem property and bind the other to the listBox2.SelectedItem.
            <TextBox Text="{Binding ElementName=listBox1, Path=SelectedItem}" Margin="12,118,0,121" Name="textBox1" Width="120" IsReadOnly="True" HorizontalAlignment="Left" />
            <TextBox Text="{Binding ElementName=listBox2, Path=SelectedItem}" Margin="138,118,20,121" Name="textBox2" Width="120" IsReadOnly="True" HorizontalAlignment="Left" />
    
  3. Build your application and run it. Notice as you select an item in the list, it displays.

The final XAML looks as follows. No changes were made to the code behind at all.

<Window x:Class="StaticResourceBinding2.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:System="clr-namespace:System;assembly=mscorlib"
    Title="Window1" Height="300" Width="300">
    <Window.Resources>
        <x:Array x:Key="StringList" Type="System:String">
            <System:String>Line 1</System:String>
            <System:String>Line 2</System:String>
            <System:String>Line 3</System:String>
            <System:String>Line 4</System:String>
        </x:Array>
        <x:Array x:Key="IntArray" Type="System:Int32">
            <System:Int32>100</System:Int32>
            <System:Int32>200</System:Int32>
            <System:Int32>300</System:Int32>
            <System:Int32>400</System:Int32>
        </x:Array>
    </Window.Resources>
    <Grid>
        <ListBox ItemsSource="{StaticResource StringList}" Margin="12,12,0,0" Name="listBox1" Height="100" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" />
        <ListBox ItemsSource="{StaticResource IntArray}" Margin="138,12,20,0" Name="listBox2" Height="100" VerticalAlignment="Top" />
        <TextBox Text="{Binding ElementName=listBox1, Path=SelectedItem}" Margin="12,118,0,121" Name="textBox1" Width="120" IsReadOnly="True" HorizontalAlignment="Left" />
        <TextBox Text="{Binding ElementName=listBox2, Path=SelectedItem}" Margin="138,118,20,121" Name="textBox2" Width="120" IsReadOnly="True" HorizontalAlignment="Left" />
    </Grid>
</Window>

Example 3 – Adding Resources to a Control

In the previous two examples, we added the resources to the main Window object. However, a resource can be added to a control.

This example will demonstrate instantiating an array as a StaticResources for a control. We will then bind a TabControl’s ItemSource property to this array. This will cause a Tab to be created for each item in the array.

Step 1 – Add the elements

  1. Add a TabControl into the default Grid control.
            <TabControl Name="tabControl1">
    

Step 2 – Add the static resources

  1. Add an xmlns reference to the System namespace. This is done by adding the xmlns:System line to as an attribute to the top Window element as shown:
    <Window x:Class="StaticResourceBinding.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:System="clr-namespace:System;assembly=mscorlib"
        Title="Window1" Height="300" Width="300">
    
  2. Create a Grid.Resources section in the XAML and add an array as a StaticResource under the Grid control.
            <Grid.Resources>
                <x:Array x:Key="TabList" Type="System:String">
                    <System:String>Tab 1</System:String>
                    <System:String>Tab 2</System:String>
                    <System:String>Tab 3</System:String>
                </x:Array>
            </Grid.Resources>
    

Step 3 – Adding Binding to the TabControl’s ItemSource Property

  1. Bind the TabControl's ItemSource property to bind to the String array.
            <TabControl Name="tabControl1" ItemsSource="{StaticResource TabList}">
    

The final XAML looks as follows. No changes were made to the code behind at all.

<Window x:Class="StaticResourceBinding3.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:System="clr-namespace:System;assembly=mscorlib"
    Title="Window1" Height="300" Width="300">
    <Grid>
        <Grid.Resources>
            <x:Array x:Key="TabList" Type="System:String">
                <System:String>Tab 1</System:String>
                <System:String>Tab 2</System:String>
                <System:String>Tab 3</System:String>
            </x:Array>
        </Grid.Resources>
        <TabControl Name="tabControl1" ItemsSource="{StaticResource TabList}">
        </TabControl>
    </Grid>
</Window>

Hey, there is nothing wrong with more examples, so if you have an example of your own feel free to add it as a comment.


Copyright ® Rhyous.com – Linking to this post is allowed without permission and as many as ten lines of this page can be used along with this link. Any other use of this page is allowed only by permission of Rhyous.com.


In Bugzilla, how can I change the password used for LDAP integration if I can’t login?

Problem

For Bugzilla authentication, LDAP is configured as the first authentication method (or the only authentication method) and the password for the user used to connect to LDAP has expired or changed.

Attempts to login result in the following error:

Failed to bind to the LDAP server. The error message was: 80090308: LdapErr: DSID-0C090334, comment: AcceptSecurityContext error, data 52e, vece�

Resolution

The change must be made manually to the bugzilla/data/params file.

Using a text editor, open the params file located under the bugzilla website and under the data folder.

Note: On FreeBSD, this was located in /usr/local/etc/www/apache22/data/bugzilla/data/params

Look for the following line to configure this manually in text:

‘LDAPbinddn’ => ‘CN=Barneck\\, Jared,OU=Support,OU=YourOU,DC=Domain,DC=tld:P@sswd!’,

As you can see the password is in clear text.  You can change it with any text editor.


Why Bugzilla fails to authenticate a local user when LDAP integration is failing?

Problem

Authentication fails with the following error even when not using an LDAP user:

Failed to bind to the LDAP server. The error message was: 80090308: LdapErr: DSID-0C090334, comment: AcceptSecurityContext error, data 52e, vece�

To me this is a straight up bug.  I am not sure if it is reported.

Cause

Bugzilla will not even try authenticate a local user using another authentication method when LDAP integration is both list first and failing. If LDAP is the first option in the authentication methods, then if the credentials are invalid, it just stops the entire authentication process and returns this error:

Business/Impact

Low.  While this could disallow all logins to the bugzilla web page, including administrator logins.  A server administrator can make a manual change to one of configuration text files.

Resolution

Authentication is configured to use LDAP then DB.  It needs to be reversed, where it tries DB then LDAP.

There is a setting called user_verify_class in Bugzilla that allows you to select the different authentication methods you want to use.  There are two places to access this:

  1. Through the web administration
  2. Through the bugzilla/data/params file

Through Web Administration

Log in as an administrator and go to Administration | Parameters | User Authentication.

Then look for the user_verify_class setting.

Click on DB and click to move it up to the top of the list.

Through the bugzilla/data/params file

Using a text editor, open the params file located under the bugzilla website and under the data folder.

Look for the following line to configure this manually in text:

‘user_verify_class’ => ‘LDAP,DB’,

Change it to:

‘user_verify_class’ => ‘DB,LDAP’,

The user_verify_class setting

This setting allows for enabling and disabling authentication as well as providing the order for enabled authentication methods.

By default only DB is enabled.  But it can be configured so that both DB, and LDAP are enabled and they can be ordered so either is first.  However, LDAP should NOT be first.  The following setting should be used.

‘LDAP,DB’,


A Bugzilla authentication dillemma?

Let me tell you the dilemma I just faced and resolved.

I have a bugzilla installation that is configured to use LDAP for authentication.  It is configured to fall back to DB authentication if LDAP isn’t available.

I have both a local user and a domain user that are admins just to resolve this situation where I can’t login as a domain user.  I can login as the local user and make the change I need.

First, let me tell you that this is a test/educational server for learning so I “fiddle” with it. Its not in production.

Well, my password changed, as commonly happens every 90 days, and I went to update the password using the local account.

No matter what I tried, I couldn’t login with the local account. My password has changed a few times and this had never been a problem.

So this is my dillemma.  I can’t login to get to the screen to update my password.

Well, I learned a few things due to this problem and I plan to post on them:

  1. In Bugzilla, how can I change the password used for LDAP integration if I can’t login?
  2. Why Bugzilla fails to authenticate a local user when LDAP integration is failing?

I  plan to make a post on both and I will link to them here when they are done.


How to use relative paths when debugging in Visual Studio 2008?

Hello everyone,

I have a project one computer in the My Documents folder. When I copy it to another user computer (under their My Documents directory) I want it to work with no tweaking.

Do Macros work? No.

My build process uses build events to copy files to an Install directory and since build events uses macros so it works perfectly. I want to use these same Macros in either or both of two debugging options:

  • Start external program
  • Working directory

So I attempt to use the same Macros:

Start external program: $(SolutionDir)\Install\Program.exe

This fails with the following error:

Working Directory:
The working directory you entered does not exist.  Please enter a valid working directory.

Same failure pretty much if I try to use a macro int he Working directory text field.

Well, that is a let down.

Do Environment Variables Work? No.

So I tried to use environment variables. They didn’t work either.

Start external program:    “%USERPROFILE%\My Documents\My Project\Install\Program.exe”

That wasn’t a good solution anyway, cause I want it to work whether copied to a Desktop or a D: drive or whatever.

What can I do?

Well, I loaded up Process Monitor for Sysinterals Suite and checked where we look. I configured it to just look for the executable.

Start external program:    Program.exe

Turns out we check for the executable relative to either of two paths:

  • In the YourProjectDir\bin\debug\Program.exe (or if you are doing a release build, YourProjectDir\bin\release\Program.exe)
  • The current working directory for Visual Studio 2008’s devenv.exe process.
    • Ok, so if Visual Studio 2008 was launched by double-clicking the the solution file, the working directory is the directory the solution file is in.
    • If you open Visual Studio using the Start | All Programs | Microsoft Visual Studio 2008 | Launch Microsoft Visual Studio 2008 shortcut, then the working directory is “C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\” (or the equivalent 32 bit path).

Ok, so it will check relative to the Project directory without putting in a macro if I open Visual Studio by double-clicking the the solution file. I can work with that.

So if I have an Install directory that contains the Program.exe and if I open Visual Studio by double-clicking the the solution file, I can put this in the Start external program:

Start external program:    Install\Program.exe

I left the Working directory blank.

It worked!

To bad if I ever forget to open by double-clicking the the solution file, and I instead use the shortcut it doesn’t work.  But no biggie, I can close and re-open correctly.

What else did I try?

I thought that if I added a relative path, it would check there.  So I should be able to put something like this:

Start external program:   Program.exe
Working Directory:    Install

But the relative path doesn’t work the same way.  Anything put there is only relative to YourProjectDir\bin\debug (or if you are doing a release build, YourProjectDir\bin\release), so this didn’t work.

I tried to use environment variables, but they didn’t work either.

I tried Macros, they didn’t work either.

I tried this:

Start external program:   Program.exe
Working Directory:    ..\..\..\Install

Nope, that didn’t work.

So what is the working directory when debugging/running from Visual Studio 2008?

I loaded up a project with an Install directory and debugging set to run the executable from the install directory.  I added this line to the program and put a break point on it:

string workingDirectory = Directory.GetCurrentDirectory();

The working directory appears to remain this:

YourProjectDir\bin\debug\ (or if you are doing a release build, YourProjectDir\bin\release\)

Oh well.

In a few weeks I am going to try Visual Studio 2010 and I will have to check if they improved this.


How to upload a file to an FTP server using C#?

C# (Mono) on FreeBSD

Ok, so today I needed to FTP a file.  It took me some time and research but I have a function that will upload a file to an FTP server.

I found a lot of examples that were very complex, and rightfully so as they have a lot of error and exception handling. However, this complexity makes it difficult to learn.

So this is a non-complex version. It follows some basic steps:

  1. Get the local file name: C:\Users\Rhyous\Desktop\File1.zip
  2. Open a request using the full destination ftp path: Ftp://Ftp.Server.tld/Path/File1.zip
  3. Configure the connection request
  4. Create a stream from the file
  5. Read the file into the a local stream
  6. Close the local stream
  7. Create a stream to the FTP server
  8. Write the local stream to the FTP stream
  9. Close the stream to the FTP server
using System;
using System.IO;
using System.Net;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
			string ftplocation = "ftp://ftp.server.tld/path";
			string file = @"C:\Users\Rhyous\Desktop\File1.zip" // Or on FreeBSD: "/usr/home/jared/test2.txt";
			string user = "Anonymous";
			string password = "AnyPasswd!";
            UploadToFTP(ftplocation, file, user, password);
        }

        static void UploadToFTP(String inFTPServerAndPath, String inFullPathToLocalFile, String inUsername, String inPassword)
        {
            // Get the local file name: C:\Users\Rhyous\Desktop\File1.zip
            // and get just the filename: File1.zip. This is so we can add it
            // to the full URI.
            String filename = Path.GetFileName(inFullPathToLocalFile);

            // Open a request using the full URI, c/file.ext
            FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(inFTPServerAndPath + "/" + filename);

            // Configure the connection request
            request.Method = WebRequestMethods.Ftp.UploadFile;
            request.Credentials = new NetworkCredential(inUsername, inPassword);
            request.UsePassive = true;
            request.UseBinary = true;
            request.KeepAlive = false;

            // Create a stream from the file
            FileStream stream = File.OpenRead(inFullPathToLocalFile);
            byte[] buffer = new byte[stream.Length];

            // Read the file into the a local stream
            stream.Read(buffer, 0, buffer.Length);

            // Close the local stream
            stream.Close();

            // Create a stream to the FTP server
            Stream reqStream = request.GetRequestStream();

            // Write the local stream to the FTP stream
            // 2 bytes at a time
            int offset = 0;
            int chunk = (buffer.Length > 2048) ? 2048 : buffer.Length;
            while (offset < buffer.Length)
            {
                reqStream.Write(buffer, offset, chunk);
                offset += chunk;
                chunk = (buffer.Length - offset < chunk) ? (buffer.Length - offset) : chunk;
            }
            // Close the stream to the FTP server
            reqStream.Close();
        }
    }
}

This works well for most files.

One problem is that this code reads the entire local file into memory, which might not be a good idea for a file that is very large (multiple gigabytes). It would be better to read the local file in bits. I upload in bits so this would not be hard to read a little bit, upload it, read a little bit more, upload it, etc…

Resources:
http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx
http://msdn.microsoft.com/en-us/library/system.io.stream.aspx
http://www.vcskicks.com/csharp_ftp_upload.php


A WPF Progress Bar

UPDATE: It turns out it would have been easier to use BackgroundWorker and MVVM so I wrote a post on doing that.A Progress Bar using WPF’s ProgressBar Control, BackgroundWorker, and MVVM

… original post below …

Today I needed a progress bar for as I was creating a c# tool that FTPs a file.  I wanted to show progress as the FTP file was uploaded.

I found a good solution at Mikes Code Blog. He has a post and a follow-up post.

WPF Progress Bar code

I created the progress bar as described and it worked. Here is a screen shot:

Thanks Mike!


Tutorial – Binding one element property to another

The properties of WPF elements can be bound to properties of other WPF Elements. Lets do some simple examples of binding one element to another.

For this tutorial, I assume you are in Visual Studio 2008.  I assume that you already know how to create a new Project and choose WPF Application.  All examples assume you have a new WPF Application.

I am the believer that one example isn’t enough, so I am going to give you three examples:

Example 1 – Binding and Element’s property to CheckBox.IsChecked

This example will demonstrate binding a Button‘s IsEnabled property to a CheckBox‘s IsChecked property.

Step 1 – Add the elements

  1. Add two items from the Toolbox:
    • CheckBox
    • Button

    The Button is named button1 and the CheckBox is named checkBox1.

  2. Change the text of the checkBox1 to “Enable button”.  This can be done either in the Properties or in the XAML.

Step 2 – Adding Binding to the Button

  1. In the XAML, locate the button1 element.
  2. Add the following to the button1 element:IsEnabled="{Binding ElementName=checkBox1, Path=IsChecked}"In your project, ElementName could be any item. In this example, we only have two elements so far: button1, and checkBox1.The XAML now looks like this (only two new lines exist):
    <Window x:Class="BindingATextBoxToASlider.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="300" Width="300">
        <Grid>
            <Button Content="Button" Height="23" Margin="12,34,416,0" Name="button1" VerticalAlignment="Top" Width="75" IsEnabled="{Binding ElementName=checkBox1, Path=IsChecked}"/>
            <CheckBox Content="CheckBox" Height="16" Margin="12,12,408,0" Name="checkBox1" VerticalAlignment="Top" />
        </Grid>
    </Window>
    
  3. Compile and run your program.
  4. Check and uncheck the box an watch the binding do its work as it enables and disables the button.

Ok, so that was pretty cool. We have a simple example of binding one Element to another.

You can shoot yourself in the foot or Don’t be stupid!

Yes, you can shoot yourself in the foot by doing something stupid.

You could bind an element to itself. Let’s try it just so you can see it happen.

Add the same binding you added to button1 to checkBox1.

Compile and see what happens.

Example 2 – Binding and Element’s property to Slider.Value

This example uses a Slider and a TextBox.

Step 1 – Add the elements

  1. Add two items from the Toolbox:
    • TextBox
    • Slider

    The Slider is named slider1 and the TextBox is named textBox1.

Step 2 – Adding Binding to the TextBox

  1. In the XAML, locate the textBox1 element.
  2. Add the following to the textBox1 element:Text="{Binding ElementName=slider1, Path=Value}"ElementName can be any item. In this example, we only have two elements so far: slider1, and textBox1.The XAML now looks like this (only two new lines exist):
    <Window x:Class="BindingATextBoxToASlider.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="300" Width="300">
        <Grid>
           <TextBox Height="23" Margin="79,62,99,0" Name="textBox1" VerticalAlignment="Top" Text="{Binding ElementName=slider1, Path=Value}"/>
            <Slider Height="22" Margin="79,34,99,0" Name="slider1" VerticalAlignment="Top" />
        </Grid>
    </Window>
    
  3. Compile and run your program.
  4. Slide the slider and watch the binding do its work as its value is displayed in the textBox1 as it changes.

Calculations in XAML Bindings are Unsupported

Ok, so maybe you want to try to do calculations in the XAML Binding. It doesn’t work.

You can enter this and while it will compile, the Binding won’t work:

Text="{Binding ElementName=slider1, Path=(int)Value}"

You can enter this and while it will compile, the Binding won’t work:

Text="{Binding ElementName=slider1, Path=Value + 1}"

Example 3 – Binding and Element’s property to CheckBox.IsChecked

Ok, lets do a slight more complex example. We are going to have more than two elements. We are going to have a ListBox that contains a list of items (ListBoxItems). We are going to have a TextBox that displays the content of the selected item.

Step 1 – Add the elements

  1. Add two items from the Toolbox:
    • TextBox
    • ListBox
  2. Add multiple items to listBox1. This can be done either in the XAML or by clicking on the button for Items in the Properties of the listBox1.

Step 2 – Adding Binding to the TextBox

  1. In the XAML, locate the textBox1 element.
  2. Add the following to the textBox1 element:Text="{Binding ElementName=listBox1, Path=SelectedItem.Content}"Notice that we are using a property of a property for the Path. This is allowed. SelectedItem is a property of listBox1, and Content is a property of SelectedItem.The XAML now looks like this (only two new lines exist):
    <Window x:Class="BindingATextBoxToAListBoxSelectedItem.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="300" Width="300">
        <Grid>
            <TextBox Height="23" Margin="12,23,12,0" Name="textBox1" VerticalAlignment="Top" Text="{Binding ElementName=listBox1, Path=SelectedItem.Content}"/>
            <ListBox Margin="12,52,12,110" Name="listBox1">
                <ListBoxItem>c:</ListBoxItem>
                <ListBoxItem>d:</ListBoxItem>
                <ListBoxItem>e:</ListBoxItem>
                <ListBoxItem>f:</ListBoxItem>
                <ListBoxItem>g:</ListBoxItem>
                <ListBoxItem>h:</ListBoxItem>
            </ListBox>
        </Grid>
    </Window>
    
  3. Compile and run your program.
  4. Select different items in the list and watch the textBox1 change to display the content of the selected item.

Copyright ® Rhyous.com – Linking to this post is allowed without permission and as many as ten lines of this page can be used along with this link. Any other use of this page is allowed only by permission of Rhyous.com.


WPF Data Binding Tutorial

Introduction

This document assumes that you understand the concepts of object oriented programming and more specifically with C# programming, such as Classes or Objects, Methods, Properties, Events, etc. If not, it will be much harder to follow along.

This tutorial will cover the basics of data Binding in a WPF application. When you are done with this tutorial, you should be able to create a basic WPF-based graphical program that uses Binding. We will cover the different types of data Binding as well as what works and sometimes what doesn’t.

What is data Binding?

The idea of data Binding is to link a variable of any Type (int, string, object, etc…) to a graphical object’s Property that has the same type.

For example, lets say you have a Button object called myButton in your GUI like this: . The words “Click Me!” is a string property in the Button object: myButton.Text.

Imagine you have a string variable called strProperty in some part of your code that on its own has no way to interact with your GUI code. Lets say you want to change the myButton.Text property to match that string variable. Binding allows the button’s text string to always match a string property in some other object not really related to your GUI so if you change strProperty to equal “Enable” your button text will look like . If you then change the strProperty to “Disable” the button text will automatically change to be without out your back end code having to make any interaction with the GUI on its own.

Without Binding, you would have to write code yourself that would interact with the GUI and update the myButton.Text property when ever you update the string in code. In order to do this without Binding, you would also have to intermingle your background code with your GUI code. This can make it difficult to update or modify your GUI because GUI code is strung throughout all parts of your application. You don’t just have to update your GUI, you have to update all your code that interacts with the GUI.

So Binding allows you to have a back end code that is independent of the GUI. This is especially useful when the GUI needs to be updated or improved or when multiple GUIs exists (skins) and you can switch between them.

There are programming styles associated with developing a GUI separate from the back-end. Two of which are Model-View-Control (MVC) or Model-View-ViewModel (MVVM). This tutorial is not going to cover these, however, it is probably wise for you become familiar with these.

However, there is no reason you are limited to Binding to back end code. You can bind to code that is in the WPF GUI and very powerful applications can be written with little to no back end code.

Requirements for data Binding in WPF

In order to using data Binding, you should have the following requirements:

  1. Your project should be a WPF Application, or your project should include a WPF Window or WPF Control.
  2. Objects your elements bind to should implement System.ComponentModel.INotifyPropertyChanged.

Types of data Binding and resources

There is are multiple types of Binding. Elements bind to some type of resource and there are multiple types of resources. Static and Dynamic resource binding which uses the StaticResource Markup Extension or the DynamicResource Markup Extension.

The Binding source can also be “any public property, including properties of other controls, common language runtime (CLR) objects, XAML elements, ADO.NET DataSets, XML Fragments, and so forth.” (Reference: http://msdn.microsoft.com/en-us/magazine/cc163299.aspx).

Go to next: 1.1 Binding one element property to another


Copyright ® Rhyous.com – Linking to this page is allowed without permission and as many as ten lines of this page can be used along with this link. Any other use of this page is allowed only by permission of Rhyous.com.