Thursday 11 April 2013

Hierarchical LDAP Queries

Want to know if a person or user is part of a group in Active Directory? Rather than retrieving a list of groups that the user is a member of and then find which groups those groups are members of until the desired group is found LDAP supports a chaining operator. Here's a handy article on MSDN that tells you how to use it: After some mucking about I found that you need to leave off the brackets surrounding the distinguished name in order to get this to work. For example
var query = string.Format(
    "(&(objectClass=group)(samaccountname={0})(memberof:1.2.840.113556.1.4.1941:={1}))",
    childGroupName, parentGroupDistinguishedName);

Wednesday 23 January 2013

Simple Visual Studio TypeScript HTML App with jQuery

I heard about TypeScript a few months ago and have had a bit of a play-around compiling some TypeScript into JavaScript using the Node.js package, but I've not had chance to try it out in Visual Studio. Here is a simple demo that shows how the code generated by the TypeScript project template can be adapted to include jQuery support.

Thanks to this stackoverflow answer for getting me started.

Step 1: Install TypeScript Plugin

Install the Visual Studio 2012 TypeScript plugin from here

Step 2: Create a Project

Create a new project in Visual Studio 2012 using the HTML Application with TypeScript project template

Step 3: Include the jQuery Type Definitions

Create a new file in the project and call it jquery.d.ts

Paste in the type definitions from from here

Step 4: Update the app.ts File

Change the code in the app.ts file to...

/// <reference path="jquery.d.ts" />

class Greeter {
    element: JQuery;
    span: JQuery;
    timerToken: number;
    
    constructor(element: JQuery) {

        this.element = element;
        this.element.text("The time is: ");
        this.span = $('<span>');
        this.element.append(this.span);
        this.span.text(new Date().toUTCString());
    }

    start() {
        this.timerToken = setInterval(() => {
            this.span.text(new Date().toUTCString());
        }, 500);
    }

    stop() {
        clearTimeout(this.timerToken);
    }

}

$(() => {
    var el = $("#content");
    var greeter = new Greeter(el);
    greeter.start();
});

Step 5: Include Reference to jQuery Library

Add the following markup to the head section of the default.htm file...

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>

Step 6: Run or Debug

Run or Debug the application to see the TypeScript in action.

You can even put breakpoints in the app.ts file.

Thursday 4 October 2012

Highcharts JS

I thought that I'd have a go trying to use the JavaScript charting library Highcharts JS. Here's a very quick example of some of the 'Wealth of Nations' data displayed as a simple line chart.

Friday 31 August 2012

Rogue-Like Game


Below is a rogue-like game implemented in JavaScript and inspired by Eric Lippert's blog articles. In deference to my old spectrum days the control keys are W, A, S, D. Find the treasure, and get out again!

Friday 6 July 2012

Online PostScript Viewer

Here's a link to a useful PostScript viewer I found online. Just paste the URL in the box!

http://view.samurajdata.se/

Friday 8 June 2012

Useful JQuery UI Tools

In my job I use JQuery and JQueryUI a lot but JQueryUI suffers from a lack of controls and does not seem to have added any new functionality for a while.

Lucky the guys that are resonsible for JQueryUI have made available a couple of controls on their site that may make it into the main UI library in the future. Here are links to the page containing demos of the controls.

Tuesday 21 February 2012

Microsoft Excel Application missing from DCOMCNFG

Trying to work with Excel Interop on a 64-bit version of Windows with a 32-bit version of Microsoft Office installed? If so you may find that you cannot set permissions on the Microsoft Excel Application node in DCOMCNFG because it is missing!

Thanks to tibb I now know that this node can be accessed using the following method...

  1. Start
  2. Run
  3. mmc -32
  4. File
  5. Add Remove Snap-in
  6. Component Services
  7. Add
  8. OK
  9. Console Root
  10. Component Services
  11. Computers
  12. My Computer
  13. DCOM Config
  14. Microsoft Excel Application