Connecting your LDAP to ClicData

With the February update (17/02) of ClicData comes the ability for our DataLoader to connect to your LDAP directory.

DataLoader can connect from any machine that is in the LDAP domain or outside of it as long as it can connect to the LDAP server.

Connect to any LDAP server using any credentials
Connect to any LDAP server using any credentials
You can also leave all the fields blank ; DataLoader will connect to the domain server as the current user
You can also leave all the fields blank ; DataLoader will connect to the domain server as the current user

Once the connection is established, you can use any standard LDAP filter to fetch anything you like.

That’s all there is to it – get data from your LDAP domain in ClicData in a matter of minutes!

LDAP Users imported into ClicData
LDAP Users imported into ClicData

Happy Dashboarding with ClicData!

How to use .NET WebBrowser to take screenshots

Do you need to take snapshot of some urls? You just want a headless browser? You are using .NET? You don’t want to rely on node/phantom or on a .net library (awesomium, cefsharp, webkitdotnet)? You love IE? Yes to all? This post is for you!

Because we can’t do a screenshot in modern browsers

If you have control of your webapplication / website that needs to take the screenshots, you know that is no such thing in current browser, no standard whatsoever (but the WebRTC is coming !). Maybe you encountered the client library : html2canvas (and  cansvg if you are dealing with svg) but this is not enough. It’s good for svg and canvas, but as soon as some html5 controls are in or complex style, it won’t do a nice job. You need a true browser that renders the page nicely, is waiting for ajax, pictures and so on, then call a method on it to get a snapshot.

Let’s emulate IE (yes, we want!)

Hopefully for you, .NET WebBrowser control is there. It is not suitable in every situation (take a coffee and read this stackoverflow post), but if you just want a snapshot of a given url, it won’t be a problem.

STAThread

First of all, you need a thread in STA (Single Thread Apartment) mode. If you want to take a snapshot from WCF or a console app, or any non-STA thread program, you need to create this kind of thread like this :

        Dim ARE As New AutoResetEvent(False)
        Dim tWebBrowserSnapshot As Bitmap = Nothing
        Dim t = New Thread(Sub()
                               Try
                                   Using tWebBrowser = New WebBrowser()
                                   ...
                                   End Using
                               Finally
                                   ARE.Set()
                               End Try
                           End Sub)
        t.SetApartmentState(ApartmentState.STA)
        t.Start()
        ARE.WaitOne()
        Return tWebBrowserSnapshot

Snapshot me

The browser is created, yeepee! You can now add some code to give it some style/size.

tWebBrowser.ScrollBarsEnabled = False
tWebBrowser.ScriptErrorsSuppressed = True
tWebBrowser.Width = myWidth
tWebBrowser.Height = myHeight
tWebBrowser.Navigate(myUrl)

Then you can take a snapshot because it has a nice method: DrawToBitmap.

Dim tBitmap = New Bitmap(tWebBrowser.Width, tWebBrowser.Height)
tWebBrowser.DrawToBitmap(tBitmap, New Rectangle(0, 0, tWebBrowser.Width, tWebBrowser.Height))

Snapshot logic

The main logic is there, but if you try that, you can run into severals issues. (such as blank image)

First, don’t forget that it’s a ‘true’ browser that renders the page. So, it takes time for it to load the page, then if it has ajax or images, it will call them, process the response etc. There is no magic flag that is set when everything is loaded on the page (to wait to call DrawToBitmap). WebBrowser has some events (such as DocumentCompleted) but it’s like the jquery $(document).on(‘ready’, fn), nothing is done yet. If you don’t know the targetted url, you don’t have a lot of choices :
– wait a finite amount of time to be almost sure everything is loaded
– maybe you can try to catch every ajax (by injecting some script into the document) the website is doing then count how many came back (but still, add a max timeout otherwise you could wait an infinite time).
– if you control the website on the url, create a variable that will be set to some value (true), and just wait for that.

Windows Registry is there for you

If you did that, you can still have blank pages. Why ? Because WebBrowser can use a old IE engine to render the page, which is not compatible. Because your server is up to date, you want to use IE11. To do that, you need to add a key in the registry.

HKEY_LOCAL_MACHINE
   SOFTWARE
      Microsoft
         Internet Explorer
            Main
               FeatureControl
                  FEATURE_BROWSER_EMULATION

Add a REG_DWORD with the process name (if you are using IIS, the process is w3wp.exe; if you are using a console app, put the name of your exe) and as data: 0x2AF9 (check msdn to see the possible values, IE10 is 0x2711).

IIS will help too

Last thing, if it’s a WCF that does the screenshot, and if you are using IIS, you need to change who is running the pool to LocalService.

Have a nice screenshot !

How to have aggregated results in a flat table

You have some nice data to display into a pivot table, but you can’t rank or format them so you are stuck ? Don’t worry!

We are currently working on the pivot table to include theses features (among others!), until then, here is a workaround using the flat table. And even more, you will learn new awesome stuff using the DataTransform feature.

For instance, let’s take a simple example with a table which has 2 columns : [Car Name] and [Quantity]. You want to display the sum of [Quantity] over [Car Name]. Basically in pure SQL it’s : sum(quantity) .. group by [Car Name] but this reduces the row count from 1000 to 5 for instance (if you have 5 cars), thus, this is not useable in DataTransform where it can just add/remove columns, ‘group by’ is not available.

What if we create a new column which is the sum of Quantity for each [Car Name] first ? Do you now the SQL “over” function ? This allows you to use aggregations that are computed for each row.

sum([Quantity]) over(partition by [Car Name])

Image

The computed column looks like :

Image

We can see that each value is repeated for each [Car Name]. (13, 6, and 8).

This is not yet useful in a flat table because of those repeated values. Let’s find a way to take only the first one. Because you can’t just remove rows in datatransform, we need to find a way to remove them using a filter on the dashboard instead.

Let’s create a new column that will help us to identify the first one for each group. To do that, we use generate a simple auto-incremented value (1, 2, .. ) and we will be able to just take the sum(Quantity) where this column equals 1 (each group will have its own sequence from 1 to n).

row_number() over(partition by [Car Name] order by [Car Name])

Image

The preview looks like :

Image

We can distinguish 5 groups : Alfa Romeo, AMC Hornet, Aston Martin, Bentley, BMW, and for each rownumber = 1, the sum of quantity : 13, 6, 8, 11, 8 (the sum is computed on the preview values only, not on the overall. It will be when you will process the transform). Thus, we can create our flat table from that and use ranking, filtering, format and so on.

Image

Image

Et voilà ! Happy Dashboarding !

Windows Server slow copy after installing NLB service

Hi everyone,

After installing the Microsoft load balancing service (NLB) between two servers we experienced a very slow copy rate when copying files/folder.
The problem was that the cluster were configured as Unicast, changing the setting to Multicast fixed the issue.

To change the setting connect to your cluster using the Network Load Balancing Manager tool then right click on the node cluster and select Cluster Properties.
Navigate to the Cluster Parameters tab and switch the parameter to Multicast.

NLB unicast multicast

More information about Unicast vs Multicast available here.
Hope this help.

Florian

Could not establish connection to IIS Server. Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)). (or Invalid namespace)

You are setting up a new server with IIS and you have another server doing remote stopping/starting of the websites, and you’re getting the following error:

Could not establish connection to IIS Server. Access is denied.

or

Could not establish connection to IIS Server. Invalid namespace.

In my case, our FinalBuilder server was throwing this error trying to stop a remote IIS website.

What you need to do is enable the IIS Management Scripts and Tools role of your IIS server:

iismanagementscriptandtools

404 error on Chrome when getting jquery minified map

With a recent upgrade of Chrome we have been seeing the following happening each time we open the console:

GET https://ajax.aspnetcdn.com/ajax/jQuery/jquery.min.map 404 (Not Found)

 

As it turns out, Chrome is trying to get the debug map for the minified version of jQuery automatically if the following setting is enabled:

Capture

 

If you do not want to see these in your console just disable this option et voila….

 

Routing traffic through VPN or local connection…

At ClicData we are not necessarily network experts , that is why we have partners that know more about it than we do.  But we dive into it sometimes as we may need to know some topics more in depth than others either because “we just have to know” or because we need to get work done faster!

We use VPN the same many other companies do, mainly for security purposes and one thing about VPN is that when you are connected, your connection is routed either through the “office” VPN server or directly to the internet from your computer and home/hotel gateway or router.

VPN routing - which way to go?
VPN routing – which way to go?

Sometimes it is best to leave the default network settings as to decide which way is best but other times you may want to control it due to security issues or mechanisms set in place that only allow you to access a specific area if it looks like you are coming from the office.

How do you know which way traffic is going?  The easiest way is to go to google.com and type “what is my ip” and the first search result is your ip address as it is seen from the rest of the world.  If the IP address is from your office gateway or from your home gateway that is an indication of where regular http traffic is going.

To force a specific destination to go one way or another all you have to do is to get a command prompt (Windows) in “run as administrator” and type “route add {the destination ip address} {the home or office gateway depending on your need} and then IF ##”

The ## is a number that you need to identify before the above command by typing a command “route print”.  The results of the route print command will list at the top all the interfaces you have setup.  You need to look for your VPN interface and lookup the number beside it as shown below:

Route print results
Route print results

So in our case the number is 56 and the full command would then be route add 9.9.9.9 1.2.3.4  IF 56 if the gateway was 1.2.3.4 and the ip address I wanted to get to was 9.9.9.9.

But what if I want all my traffic to go through the VPN when I am connected to the VPN?

Well then, right click on the VPN connection properties and make sure the checkbox beside “Use default gateway on remote network” is checked.

Route all traffice via VPN default gateway
Route all traffice via VPN default gateway

Hope this helps someone…

Fiddle me this! Add a header to all requests regardless of calling application…

At ClicData we love Fiddler… For those that don’t know Fiddler is a windows application that allows you to see what’s going on between your browser and the server.  Think of it as the app that keeps an eye on everything that your computer sends and receives to the internet.

Fiddler is one of the few tools that does this  job very well and when debugging web services, web sites, security issues, and all types of http and https communication, it offers tremendous power and flexibility.

Nicolas already blogged about ways to debug WCF Services with it in this blog.  Today I would like to let you know about one feature that is quite cool.

When using secured web services like we do at ClicData sometimes we need to send “hidden” tokens in the header.  So testing the web service using a browser becomes quite difficult since we typically get Access Denied (401) or a validation error.

So with Fliddler you can just access Composer and type your URL and using GET/POST, etc… build your header:

2013-06-06 20-50-42

So for example, if we wanted to ensure that the web service returned JSON data as opposed to the default (in our case XML) we could add this “accept: application/json” to the Request Headers text area.

However, my issue was that I wanted to use Microsoft Excel to connect directly to the web service.  As it turns out we are currently working on supporting OData so you can connect to your data directly with Excel but our security was not letting Excel connect to it.

So after consulting this entry in Fiddler’s web site it was fairly easy to modify Fiddler to automatically add a header regardless of the application that calls it.  In our case we wanted to add oSession.oRequest[“AuthorizationKey”] = “xxxxxxx-xxxxx-xxxxxxxxx-xxxxxx”; to each request.

2013-06-06 20-49-16

Access Fiddler’s Rules –> Customize Rules menu

2013-06-06 20-49-43Write a little script to add a header to each request before sending 

If you are using Windows Azure, a similar technique is used in this blog post to access storage data using Excel.

SSAS CellPermission error on Excel or SSMS

Hi

Today I ran into some issue while connecting to a SSAS cube using Excel, some of the measure where showing #Value! instead of the actual value.
After some investigation I found the message “#Error CellPermission (1, 1) The member ‘[CubeName]’ was not found in the cube when the string, [Measures].[MeasureName], was parsed.

When I browsed the cube using SSMS and the same user’s role I could see the message as well so I checked the security role and found the issue.

In your policy all Measure are accessible to this role so I edited the role (double click on it) then go to the “Cell Data” page

Role

Enable the read and the read-contingent permissions for the role and select the Measures (in this case all of the Measures)

Cube Role

I hope this helps.

Florian

How to vertical-align an element in css using flexbox

Forget about :

  • display: table
  • display: table-cell
  • height: 100px / line-height: 100px / line-height: 1
  • top: 50% / margin-top: -25px
  • or why not some JS ? parent.style.marginTop = “-” + (parent.clientHeight/2) +”px”;

You can use the css flexbox layout to do that without any trick, and being more configurable.
You just have to set some flexbox properties on the container that contains what you wish to center.

If you haven’t heard of flexbox, go to read W3C Spec or more friendly Using CSS flexible boxes for instance.


<div class="container">
    <span>I wish I could be centered</span>
</div>
<hr />
<div class="container">
  <span>I wish I could be centered</span>
  <span>I wish I could be centered</span>
</div>

.container {
   display: flex;
   flex-direction: row; /* default is row */
   justify-content:center; /* default is stretch */
   align-items: center; /* default is flex-start, center is like a text-align: center in our case (because we are in row mode) */
   height: 200px;
   width: 500px;
   background: #aac;
}
.container > * { padding: 5px; border: 1px solid black; background: white; }

The result is http://jsfiddle.net/derste/jhuH5/1/ :

flex hcenter
Using flex-direction: column, the result would be :

flex vcenter

Chrome support

Just add the well known “webkit-” in front of flex properties.

.container {
    display: -webkit-flex;
    -webkit-justify-content: center;
    -webkit-align-items: center;
    height: 200px;
    width: 500px;
    background: #aac;
}

Firefox support

Using firefox, you need to enable the flexbox (disabled by default) (yes, ask your users to do it, right) :
firefoxflex

Cross-browser

Well, for now, only Chrome (>=21) has a good support using -webkit prefix, Firefox is using the W3C notation (>=22) with the trick in about:config, Opera (>=12.10) works, IE10 and Safari are using the old draft of flexbox, so not compatible.

Have fun !