Add New Admin User in Windows 2012 Server

Adding a new admin user will be divided into two actions: first the creation of the new user and then secondly the assignment of the user to the admin group.

Connect to the Windows 1012 Server with Remote Desktop click on little down arrow at the top bar

Select start and then click on the server manager icon (what happened to the small icons?)

In the black bar at the top click on tools and select computer management

Add New User

To add a new user expand Local Users and groups in the tree menu on the left.

Select Users

Right click on the centre pane. For a new system there is Administrator and Guest listed.

Select New User from the popup window and enter the details for the new user.

Add User To Administrator Group

Expand Local Users and groups in the tree menu on the left

Select Groups

Double click on Administrators Properties

Click on Add to add a user to the group

In the box enter the name of the user and then click on check names. Accept the user.

Creating Content Border with Images

Website content blocks, often called modules, or widgets, can be surrounded by borders to make them stand out. Perhaps notepad paper or an old parchment.

Different surrounds and backgrounds can be used to make the content pleasing to the eye and to add distinction. The styling enables the content to be categorised either by content or importance.

CSS3 allows for the replacement of some of the older work, for example borders with radius corners and drop shadows.

However, to implement graphic design surrounds, an image is still chopped into segments, as previously.

Where possible the segments are created such that either a horizontal or vertical repeat can be implemented.

Care is taken to ensure that frilly or castellated edges are seen to blend smoothly, not with a jagged edge, step, or hard change of colour.

A repeat allows for an efficient use of downloaded images, keeping the weight of the web page downloaded to a minimum and allowing for expansion of the content area according to the content added.

The two methods generally employed to provide this border styling are tables and divs.

In both methods the image design is chopped up into segments which are either corners or repeats for the sides. There may also be background styling for the content within the block.

The smallest table is based upon a 3×3 grid. Whilst the div method uses a number of divs stacked one above the other.

Borders Using Tables

An example of the table layout is given below. It uses a combination of fixed size table cells.

<table>
<tr>
<td width="6" height="6" background="/images/topleft.gif">&nbsp;</td>
<td width="100%" height="6" background="/images/top.gif" height="6">&nbsp;</td>
<td width="6" height="6" background="/images/topright.gif">&nbsp;</td>
</tr>
<tr>
<td width="6" height="100%"><img src="/images/left.gif" width="6">&nbsp;</td>
<td width="100%" height="100%" >Content is added here</td>
<td width="6" height="100%"><img src="/images/right.gif" width="6">&nbsp;</td>
</tr>
<tr>
<td width="6" height="6" background="/images/bottomleft.gif">&nbsp;</td>
<td width="100%" height="6"><img src="/images/bottom.gif"  height="6">&nbsp;</td>
<td width="6" height="6" background="/images/bottomright.gif">&nbsp;</td>
</tr>
</table>

Here’s an image showing a container with blue and white edges, with a yellow background for the content

Creating ontent border with images: grid of images

Perhaps a little small to view properly, so here it is enlarged:

Creating content border with images: grid of images (enlarged)

As can be seen the corners are of a fixed size. The sides joining them are set to be the full length of that side. As shown the edge middle sections are 6px in length. To minimise the saved image this could be 1px.

The side and top/bottom images are set to to match the width (6px) or height (6px). These images will then be repeated within the table cell.

The table cell in the centre is the content area. Within this area will be added the appropriate code for the CMS to generate the content.

I have found that to ensure the desired results the images added along the top and sides should be specified fully, to avoid the browser making guesses as to your intent.

The table code above can be improved upon by adding CSS class references and moving the image and sizing to CSS.

For example here’s a 3×3 table with the HTML layout and associated CSS.

<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="BlueBorder-tl"></td>
<td class="BlueBorder-tc"></td>
<td class="BlueBorder-tr"></td>
</tr>
<tr>
<td class="BlueBorder-cl"></td>
<td class="BlueBorder-cc">
Content goes here
</td>
<td class="BlueBorder-cr"></td>
</tr>
<td class="BlueBorder-bl"></td>
<td class="BlueBorder-bc"></td>
<td class="BlueBorder-br"></td>
</tr>
</tbody>
</table>

In the CSS below, I have merged the corner images together as a single image. This is then positioned to show the desired corner.

/* begin Box, BlueBorder */


.BlueBorder-tl
{
	width: 6px;
	height: 6px;
	background:url(images/BlueBorder-corners.png) no-repeat;
}

.BlueBorder-tr
{
	width: 6px;
	height: 6px;
	background:url(images/BlueBorder-corners.png) no-repeat;
	background-position: -6px 0px;
}

.BlueBorder-bl
{
	width: 6px;
	height: 6px;
	background:url(images/BlueBorder-corners.png) no-repeat;
	background-position: 0px -6px;
}

.BlueBorder-br
{
	width: 6px;
	height: 6px;
	background: url(images/BlueBorder-corners.png) no-repeat;
	background-position: -6px -6px;
}

.BlueBorder-t
{
	height: 6px;
	background: url('images/BlueBorder-t.png') repeat-x;
}

.BlueBorder-l
{
	height: 6px;
	background: url('images/BlueBorder-l.png') repeat-x;
}

.BlueBorder-r
{
	height: 6px;
	background: url('images/BlueBorder-r.png') repeat-x;
}

.BlueBorder-b
{
	height: 6px;
	background: url('images/BlueBorder-b.png') repeat-x;
}

/* end Box, BlueBorder */

 

Borders Using DIVs

The div method uses a number of divs either stacked on top of each other or absolutely positioned to give the same effect.

<div class="topLeft">
 <div class="topRight">
  <div class="top">
   <div class="left">
    <div class="right">
     Content is added here
    </div>
   </div>
  </div>
 </div>
</div>

Like the use of tables the original image is chopped up into segments which are then put back together.

In the div method all the items are of the same size the background images are moved to their appropriate edge and the repeat set for the x or y direction accordingly.

For example the top left corner is set using:

.topLeft{
background:url(/images/topleft.gif) no-repeat
}

I have found using this method that there is a need to stack the DIVs in a correct order to ensure that the edges and overlaps of the backgrounds match up and can be viewed correctly.

I have also used a method whereby each div is referenced sequentially with the use of absolute positioning moving the div to its required location.

Creating content border with images using divsThe image above shows an example of the result. In this case I have used a fixed width for the div sizing. It would be normal to allow 100% sizing, the div taking the full width of its bounding container.

Again the DIVs are stacked, but in many respects the code looks simpler to view and there is less chance of omitting one of the closing tags </div>.

Note how the edges are constructed first, allowing the corners to sit on top hiding the continuous edges.

<div class="border">
 <div class="top">
 <div class="left">
 <div class="right">
 <div class="bottom">
  <div class="topLeft">
  <div class="topRight">
  <div class="bottomLeft">
  <div class="bottomRight"> 
   <div class="content">Content is shown here </div>
  </div>
  </div>
  </div>
 </div>
 </div>
 </div>
 </div>
 </div>
</div>

And the associated CSS to position the above elements:

 .border{ position:relative; }
 .top{
 position:absolute;
 width:100px;
 height:100px;
 top:0px;
 left:0px;
 background:url(images/GreyBorder-t.png) repeat-x;
 background-position:0 0;
 }
 .left{ position:absolute;
 width:100px;
 height:100px;
 top:0px;
 left:0px;
 background:url(images/GreyBorder-l.png) repeat-y;
 background-position:0 0;
 }
 .right{
 position:absolute;
 width:100px;
 height:100px;
 top:0px;
 left:0px;
 background:url(images/GreyBorder-r.png) repeat-y;
 background-position:100% 0;
 }
 .bottom{
 position:absolute;
 width:100px;
 height:100px;
 top:0px;
 left:0px;
 background:url(images/GreyBorder-b.png) repeat-x;
 background-position:0 100%;
 }
 .topLeft{
 position:absolute;
 width:100px;
 height:100px;
 top:0px;
 left:0px;
 background:url(images/GreyBorder-tl.png) no-repeat;
 background-position:0 0;
 }
 .topRight{
 position:absolute;
 width:100px;
 height:100px;
 top:0px;
 left:0px;
 background:url(images/GreyBorder-tr.png) no-repeat;
 background-position:100% 0;
 }
 .bottomLeft{
 position:absolute;
 width:100px;
 height:100px;
 top:0px;
 left:0px;
 background:url(images/GreyBorder-bl.png) no-repeat;
 background-position:0 100%;
 }
 .bottomRight{
 position:absolute;
 width:100px;
 height:100px;
 top:0px;
 left:0px;
 background:url(images/GreyBorder-br.png) no-repeat;
 background-position:100% 100%;
 }
 .content{padding:8px;}

Thoughts

I have found using a 3×3 table with border edges and a central content area was most successful.

The use of stacked DIVs with positioned images and the use of relative and absolute positioning didn’t always work, for example as a DotNetNuke container. The JavaScript associated with the container elements couldn’t derive the position and tended to then misplace the required action menu.

For efficiency there is an advantage to creating a single image comprising the components to be used. Only the single image is then downloaded which saves on the overhead employed in asking for each image download, checking it’s version.

The single image is then positioned as required. This is like taking a larger image and moving it behind a window cutout to show the desired section.

As shown in the examples above the border images are quite simple. The container themes below are more akin to this style of table and div layouts.

creating content border with images examples

SDDM Fails to Show, Requires Command Line Login First

The computer was showing a command line login. The SDDM login was failing to show.

Once logged in, if I waited a while and then pressed any key the SDDM login screen would appear. Username and password to be entered as usual.

Interestingly in the top bar it was the US layoutwhich was selected (no others available).

I also found that entering the wrong password I was returned to the login screen once more, where the gb layout was shown.

Through searches on the Internet I found this reference

https://forum.manjaro.org/t/sddm-very-slow-to-show-up/46361/5

Whilst not my answer, the included reference to this article

https://forum.manjaro.org/t/sddm-not-loading-properly-on-boot/34484

provided the solution.

The recommendation was to add the haveged package.

First install the package: apt get install haveged

Whilst the recommendation was to enable and start haveged:

systemctl enable haveged
systemctl start haveged

I chose to restart the conmputer to viewwhether the problem was persisting.

Problem solved! Albeit still with US layout.

Add IIS URL Rewrite

By default IIS is missing the URL rewrite.

Looking at a fresh install of IIS admin view, the icon which should be found within the section, IIS, is missing.

Having gone through the sequence to add asp.net as detailed in the article Adding ASP.NET Features to IIS7.5, I expected to find it as an option here.

Adding ASP.NET Features in IIS 7.5 Including ASP.NET

But it’s not listed.

To add this visit the page https://www.iis.net/downloads/microsoft/url-rewrite and follow the instructions, downloading and running the module.

Here’s a view of the IIS admin screen with the URL Rewrite icon, sitting between the Server Certificates and Worker Processes on the bottom row of the IIS section.

Add IIS URL rewrite, icon added

 

 

Add Scroll Top Image

When the web page has scrolled down an offset distance show a scroll to top image.

When redesigning the VNTweb website, thinking about the longer article pages, I chose to add one of these.

Scrolling the page down shows on image in a fixed location. Clicking on this image shall scroll the page back to the top of the page, or a named div.

I wanted my scrolltop image to appear once the page had scrolled down by a measure.

Here’s what I used

 
$VNTweb(window).scroll(function(){ 
  if ($VNTweb(this).scrollTop() > 100) { 
    $VNTweb('#scroll').fadeIn(); 
  } else { 
    $VNTweb('#scroll').fadeOut(); 
  } 
});

Once the page has scrolled down by 100 pixels then the scroll image becomes visible.

And for the image onClick scroll action I used the scroll from my article JQuery Page Scroll on Load, a few weeks ago.

$VNTweb('#scroll-top').click(function(){ 
  $VNTweb("html, body").animate({ scrollTop: 0 }, 600); 
  return false; 
}); 

You may wish to experiment with the distance scrolled before showing the image. Perhaps 100 pixels is too soon.

Another idea would be to hide and show the image at different values.

For example show the scroll to top image when the page has scrolled down a distance of 400 pixels, but hide once more when the distance reaches 300.

If you are looking for suitable images take a look at Font Awesome or Glyphicons.

Determine Subroutine Click Event Trigger

Using one sub-routine to handle more than one link button click event requires determination of which button click triggered the sub-routine.

I had an existing subroutine handling a link button. Examining the entries in a form, updating a database and sending an email. A second button was required on the form which would update the database but not send the email.

Options were:

  1. Clone the sub-routine omitting the email sending
  2. Two subroutines to handle the click events with each calling a common function where the difference between the two actions is to be determined. Or just the common block of code for saving the form values.
  3. One subroutine to handle the two click events with the email sending determined by which link button was clicked.

For a quick solution I chose option 1 – clone the subroutine.

However, with time available later I was interested in implementing option 3 – one subroutine handling two click events with a part of the code in the subroutine determined by which link button triggered the event.

In the code below the two link buttons are declared, followed by an outline subroutine to handle the clicking of the two buttons.

'Declare two link buttons with event handling
Dim WithEvents cmdSave as System.LinkButton
Dim WithEvents cmdAdd as System.LinkButton'Sub routine to handle the clicking of either button.
'Run common block of code in sub routine
'Determine event was triggered and run an optional block
Private Sub cmdLButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click , cmdAdd.click
  'common block of code here (update database)
  'Code here specific to one item
  If sender = cmdAdd  Then
    'send email to applicant confirming form submission
  End If
  If sender = cmdSave Then
    'send email to applicant confirming form submission
  End If
End Sub

A test is made to determine which of the two link buttons was clicked.

In the example above I have shown each as their own separate if statement. When I developed this further I replaced the if statements with a select.

Shown below is a part of the updated

missing the right buttons/commands, would be better to base this upon the GridView edit/update/delete automation

 <asp:GridView ID="gdvCU" runat="server"
    AllowPaging="false"
    AllowSorting="false"
    AutoGenerateColumns="false"
    >
  <Columns>                            
    <asp:TemplateField ItemStyle-HorizontalAlign="left" ItemStyle-Width="80%">
      <ItemTemplate>
        <asp:RadioButton ID="rbnOption" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Text")  %>' GroupName='<%# DataBinder.Eval(Container, "DataItem.Value")  %>' Checked='<%# DataBinder.Eval(Container, "DataItem.Selected")  %>' AutoPostBack="true" OnCheckedChanged="DeselectSelected" />
      </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField ItemStyle-HorizontalAlign="Left" ItemStyle-Width="20%">
      <ItemTemplate>
        <asp:LinkButton ID="cmdCU" runat="server" Text="Send" CommandName='<%# DataBinder.Eval(Container, "DataItem.Value") %>' CommandArgument='<%# DataBinder.Eval(Container, "DataItem.Value") %>' CausesValidation="false" Visible='<%# DataBinder.Eval(Container, "DataItem.enabled")  %>'></asp:LinkButton>
        <asp:Label ID="FruitId" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.FruitId") %>' Visible="false"></asp:Label>
      </ItemTemplate>
    </asp:TemplateField>    
  </Columns>
</asp:GridView>

The Associated subroutine to handle the above gridview and its submission.

Protected Sub cmdCURegister(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) Handles gdvCU.RowCommand
  Try
      Select Case e.CommandName
        Case "Registered"
          'action here if visitor is registered
        Case "NotRegistered"
          'action here if visitor is not registered                      
      End Select
    End If

  Catch exc As Exception 'Module failed to load
    ProcessModuleLoadException(Me, exc)
  End Try
End Sub

What about option 2?

Having satisfied my interest with the common subroutine with a test to determine the source and choose the appropriate action I never implemented option 2.

Composite SQL Field with null Value Returns Blank

The intent was to join the address fields as a single returned value from a database query select. But I found that if one of these fields was null, the whole returned result was empty.

I had an address, in the usual way, across a number of database fields: address; town ; postcode and county.

I wished o let the database query do the work, joining the fields, as opposed to the VB/C# code.

The SQL query to join these fields as a single composite field value.

Shown below is my first version of the composite field value, derived from the individual address parameters.

‘Street: ‘ + building.address + ‘, Town: ‘ + building.town + ‘, Postcode: ‘ + building.postcode + ” AS Location

My original expectation was that if one of these address fields was null then that part would be shown as blank.

For example with no town the returned entry might be:

Street: Broad Street, Town: , Postcode:  Rg1 1AA

I found that whilst I could readily create a string composed from the individual fields on occasion the result was empty, even though I knew at least one field to have a valid value.

Investigating I showed that if one of the fields was empty (null) then the whole combined field had a null value.

The building location was to show the address, as street, town and postcode.

‘Street: ‘ + building.address + ‘, Town: ‘ + building.town + ‘, Postcode: ‘ + building.postcode + ” AS Location

As can be seen its a simple string addition of the individual fields.

However, if there was no entry in one of the fields, ie. it was null, then the whole result returned as an empty field, as opposed to the single empty entry.

To correct the empty result error I added an isnull test for each field, taking either the database value or an alternative presentational value, In this instance a couple of dashes to indicate that there is no entry.

‘Street: ‘ + ISNULL(building.address,’–‘) + ‘Town: ‘ + ISNULL(building.town,’–‘) + ‘Postcode: ‘ + ISNULL(building.postcode,’–‘) + ” AS Location

Shown above is the previous example with the addition of the isnull.

For our earlier example this gives:

Street: Broad Street, Town: –, Postcode:  Rg1 1AA

Adding ASP.NET Features to IIS7.5

By default Windows 7 IIS is missing the asp.net features, shown above the IIS section in the control panel

The control panel is shown below with only the IIS options and Management options.

Adding ASP.NET Features in IIS 7.5

To add the asp.net features. Begin by opening the control panel and selecting from the Programs section the option Turn Windows features on and off.

Adding ASP.NET Features in IIS 7.5 Windows Features

Click on the checkbox for ASP.NET.

 

Adding ASP.NET Features in IIS 7.5 Windows Features add ASP.NET

There’s a dialogue window confirming that the amendment is taking place:

Please wait while Windows makes changes to features. This may take several minutes.

You may find that this takes a few minutes. Wait whilst the dialogue completes.

I have read that IIS is to be restarted for the change to show. However, for me it was sufficient to close the management window and reopen it once more.

 

Adding ASP.NET Features in IIS 7.5 Including ASP.NET

 

Whilst the control panel ASP.NET section is missing by default its easy to add it in, following the steps above beginning with the control panel.

 

Create Website Thumbnails from the Command line

Creating a new portfolio page for a website I was looking for a simple to use thumbnail creator.

The thumbnail creator should have the following criteria:

  •  minimum of steps, one would be ideal
  • easily repeatable
  • consistent output sizing

I wanted to avoid:

  • resizing the browser to specific dimensions for the next batch. Once closed reproducing the exact sizing from before is problematic
  • not reliant on an external reference, such as the old thumbnail service by Alexa, or the ShrinkTheWeb.

I knew that I could take a screenshot of the browser, either with one of the browser tools or a screen capture program. This could then be transferred to the Gimp for image editing and saving. Or maybe save the images and do a batch conversion with a tool such as XnConvert.

I wanted to keep the thumbnail creation both simple and easily reproducible.

Looking through my previous articles I one about taking screenshots from the command line using wkhtmltopdf.

neil@local:~$ wkhtmltoimage –width 1200 –height 1000 http://www.traditionalrestoration.co.uk traditionalrestoration.co.uk.jpg

It was easy to put in the website address, an appropriate file name and click return. Done within a few seconds I had a thumbnail of a website capture and saved. Replace the website URLs to work my way through the list.

Create websites from command line: traditionalrestoration.co.ukI did find that pages employing flash had empty spaces. For example this one from Lily Oakes’ website, which incorporates content from YouTube.:

Create websites from command line: lilyoakes.co.uk

Also one or two with sliders, which were taking longer to render, had missing content. These would be later visited using the slower more fiddly method with browser, screenshot and Gimp.

 

Hide Admin Messages from Subscribers

Do you want all your WordPress logged in users to see your system messages?

Messages declaring pending plugin updates, a WordPress core update, or a notification from a plugin, all visible to any logged in user.

Lets keep the info given to registered users of your website to a minimum. We don’t wish to tell them about the status of the website.

There are a couple of areas to target:

  • Admin notifications
  • The notification bar

WordPress provides hooks to actions covering both of these areas.

By checking the capabilities of the user we can determine whether we wish to show the info.

The restriction uses actions and filters added to the file functions.php in the theme.

Admin Notifications

Perhaps the most important.

Checking to see whether the user is able to update the core first, this function determines whether to show admin notifications.

function show_update_notice_admin_only()
{
    if (!current_user_can('update_core')) {
        remove_action( 'admin_notices', 'update_nag', 3 );
    }
}
add_action( 'admin_head', 'show_update_notice_admin_only', 1 );

Notification Bar

At the top of the page there is the notification bar. Lots of content on this bar we don’t want non-admin users viewing.

So can we hide it ? – Yes, using filters.

This time we are testing to see if the user is unable to perform a couple of actions.

The first test is the management of options.  If the user is unable to do so then hide the admin notification bar.

Similarly the second test checks whether the user can update posts. If this isn’t possible then again the admin notification bar is hidden.

// show admin bar only for admins
if (!current_user_can('manage_options')) {
	add_filter('show_admin_bar', '__return_false');
}
// show admin bar only for admins and editors
if (!current_user_can('edit_posts')) {
	add_filter('show_admin_bar', '__return_false');
}