In this part I will start to show how to controll input fields so it will end up okay in the Active Directory.
We will start with the 2 textboxes for Given Name and Surname.
As It is now we can write like fREDRiK and WALL in these fields and the input to the Active Directory will be exactly the same. Not so nice for us.
In this series we have an event when leaving the textbox. So we can use that for this control too.
Then we will see the change when we hit TAB or click on Another TextBox. This is pretty nice
$txtBoxGivenName_Leave={ $CurrDir = (Get-Location -PSProvider FileSystem).ProviderPath $NotOKImage = [system.drawing.image]::fromfile($CurrDir + "Close-2-icon.png") $OKImage = [system.drawing.image]::fromfile($CurrDir + "Ok-icon.png") # Check the Given Name TextBox if ($txtBoxGivenName.Text -eq "") { $pictureboxGivenName.BackgroundImage = $NotOKImage $txtBoxGivenName.Focus() $statusbar.Text = "You need to write something in the Given name box!" $formCreateADUsers.Update() return } else { $UpperFirst = $txtBoxGivenName.Text.ToLower() $UpperFirst = $UpperFirst.substring(0,1).ToUpper() + $UpperFirst.substring(1) $txtBoxGivenName.Text = $UpperFirst $pictureboxGivenName.BackgroundImage = $OKImage $formCreateADUsers.Update() } }
The $UpperFirst variabel is where the new stuff happens.
First of all we take the text in $txtBoxGivenName and make it to lower.
Then we take the first letter and make it to upper. In this way we have our Given name and Surname to start with a upper letter.
And the result will be like below.
Do the same for the Surname!