Current Stories
PermaLink Plaxo Just plain tries harder06:25 PM
As someone that pretends to be on top of the whole "Internet" thing, I try to maintain accounts on all of the services, and keep abreast of all the social networks, and all the various communications methods on the Internet. This of course is a silly and foolish goal, but, none the less...

facebook is by far the leader in the social game (some would claim winner), that being said, I really have to give kudo's to Plaxo. Although their membership is really limited to the nerds right now (that may never change), their integration with anything and everything is very admirable. As an old Apple fan (from pre-Mac, pre-windows, pre-IBM and pre-PC stantpoint) I know that a lot of superior technologies don't win.   The Apple ][ came more open than anything that has ever been in my mind.   The resource manual came with the bios commented source code and fold out schematic of the motherboard.   I don't think Plaxo will ever really "be" anything, but, I think they are worth taking a look at, if only for academic purposes.

(3269)

PermaLink Windows Impersonation01:41 PM
From time to time I have needed to perform actions on a domino server that required NT authentication. Anyone who has tried this before, knows that in most cases that authority that is used is the system account for the specific server that is running, and this account generally does not have access to anything anywhere else.

Recently I ran across a database that Kevin Pettitt put together to perform access to a remote share, after sharing my solution with him he reminded me that I need to post this.

So, here is it. I wrote it mostly by trial and error, but from what I understand its doing behind the scenes is to change the ownership of the current thread so that all operations are performed under a new identy.

So, far I've used it to read and write remote file shares, issue SQL calls, and issue ADO and WMI commands. There are other ways of doing each of those things, but, this way works for all things (that I've tried) that require NT authentication.


'Class.Impersonate: Option Public Option Declare Declare Private Function LogonUser Lib "advapi32.dll" Alias "LogonUserA" (Byval lpszUsername As String, Byval lpszDomain As String, Byval lpszPassword As String, Byval dwLogonType As Long, Byval dwLogonProvider As Long, phToken As Long ) As Long Declare Private Function ImpersonateLoggedOnUser Lib "advapi32.dll" Alias "ImpersonateLoggedOnUser" ( Byval hToken As Long ) As Long Declare Private Function RevertToSelf Lib "advapi32.dll" Alias "RevertToSelf" () As Long Declare Private Function CloseHandle Lib "kernel32.dll" Alias "CloseHandle" ( Byval hObject As Long ) As Long Private Const LOGON32_LOGON_NEW_CREDENTIALS& = 9 Private Const LOGON32_PROVIDER_WINNT50& = 3 Class WinImpersonate Private hToken As Long Sub new( Username As String, domain As String, password As String) Dim retval As Integer retval =LogonUser(UserName, Domain, Password, LOGON32_LOGON_NEW_CREDENTIALS&, LOGON32_PROVIDER_WINNT50&, hToken)
If RetVal <> 0 Then RetVal = ImpersonateLoggedOnUser( hToken ) If RetVal = 0 Then If hToken <> 0 Then CloseHandle( hToken ) End If End If Else ' retval = GetLastError()
End If End Sub Sub delete If hToken <> 0 Then CloseHandle( hToken ) Call RevertToSelf() End If End Sub End Class
This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.


(2)

PermaLink More remote desktop tips, non-standard screen sizes04:47 PM
From Time to time I use my Wife's laptop, its not often, but, I do from time to time. Mostly what I do with a laptop, is remote desktop back into a computer either in the data center or at home. That way I have all my application configured just the way that I want them. Her laptop has a 1680x1050 wide screen resolution screen, which i suppose is fine, but, when used with remote desktop, its not one of the supported resolutions. The impact of this is that it will downsize to the nearest supported resolution, for her's its 1600x1050, but, if you switch, to windowed mode then back to full screen, it will not go into full screen. Up until now, my way around this, instead of minimizing a window full screen session, I would just kill it and restart it, which is much, much slower. You can specify a non-standard size directly in the RDP file, which is just a text configuration file. Here are the important settings desktopwidth:i:1680 desktopheight:i:1050

(73)

PermaLink Remote desktop at home and port numbers12:01 PM
I am a HUGE fan of remote desktop, My server lab used to contain swarms of computers, mostly junk, used for single purpose, often I would go months without using one or the other, but, when I needed it I could just turn it on and have a pre-configured {fill in the blank} server that is up and running to play with.

Enter Virtualization.

My number of test machines has absolutely exploded, I now have single purpose virtual machines, I can clone easily dispose of failures quickly, come back to successes later.

Each of my test machines is just a few files on a 6 drive, Quad core server at home, which also serves as a hardware mirror for a production server.

As my dependancy increased, my productivity "away" decreased, when I'm on the laptop, I found myself connecting to one machine at home, then from there daisy chaining to another machine so, I have an RDP session inside an RDP session.  Although this works, its not as productive as having direct connections.

My home router does port forwarding and I get to "choose" which machine or virtual is becomes the weakest link.

Recently, I've discovered the registry keys (on XP) to move the RDP service to an alternative port.   By default RDP is on port 3389, for my purposes, I change the last two digits of the port number to the last two digits of the IP address.

So, for the machine that would have the IP address 192.168.1.15 at home would be on port 3315.   This allows me to save RDP connection files for homeaddress:3315 and connect directly to that machine.

Here are the registry keys that I use:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts\List]
"3389:TCP"="3389:TCP:*:Enabled:@xpsp2res.dll,-22009"
'this key is only necessary if you are using windows firewall
'I change this to:
"3315:TCP"="3315:TCP:*:Enabled:@xpsp2res.dll,-22009"


[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp]
"PortNumber"=dword:00000d3d
'00000d3d is the hex value for 3389, the Hex value for 3315 is cf3

Once those values are changed when the machine reboots, it comes back up using the new port, then all that is needed it to perform port forwarding at the router


(17)

PermaLink Screen capture, the easy way.09:56 AM
Have you read a page, thinking that you would come back to it, but, later can't find it, or any reference of it, or any external confirmation that it was not just completly imaginary?

I've been asking everyone I know, "did I tell you about..." followed by, "did I send you a link to...?"

The
JingProject allows you to capture either a screen, or video from your screen, similar to other products, with a difference of allowing very tight integration with their a web host.

After you complete your capture, it allows you to upload your video or screen capture directly to their web server and a URL is left on your clipboard.

Think Instant Message.

You're in a converstaion with someone, trying to describe something unsucuccessfully.

Click a hotkey (I chose control+alt+J)
Select the window or screen region that you want to capture
Click Video
Perform the action
Click Stop
Click Share
go back to your chat window and paste the URL

Its magic and exceptionally cool and simple.

(60)

PermaLink Freebie SNTT for the Californians! Validating mailing addresses.12:05 AM
Well the whole west coast actually, Im pretty sure its already tomorrow in Asia.

I recently inherited a database that, at one time had a bad input translation formula (no relation to previous post),  but, as the result, all the zip codes on all the documents were zapped, proir to my comming on board..

There really was not that much data, but, I figured it was time to dig into google maps api and come up with a programatic solution.

I know that I get pretty good results pasteing partial addresses into the search bar, it comes back with whatever it can, formatted as well as it can.

I was quite amazed at how much data I could forget, and still come back with valid results.

I bookmarked this one a while ago, I new that I would come back to it at some time and it ended up being today.  

http://econym.googlepages.com/example_geo.htm

Most importanly when I click the "Go!" button, while fiddler is running it shows me the data that goes back and forth, its pretty clear what the URL syntax is and what the parsing method is.

In the case of the example, they use,  what years ago,  I called dynamic javascript.   Now that this sort of thing is in vogue, Im sure its got a flashy name, but I don't know what it is.  I'm pretty sure that even though it has JSON in the URL, its not "real" JSON because its directly executed, but, none the less, I digress.   I'm really much less interested in the name than how it works.

On to the code!


(1)

PermaLink Consistant formulas11:19 PM
By my watch, in central time, its still thurday, so I'm posting this as SNTT even though theres very little Thursday left.

I sometimes I just fustrated performing the same tasks over and over again inside the domino designer.

Often times this can't be helped, like when you have a whole bunch of rows and each one of them gets a slightly different hide formula, or a separate cell class on each cell in a column or whatever.

I recently ran into a case where I was doing a web survey, with radio buttons that should formatted the same throughout the form, but, "the same" was going to change.

I know that we needed consistent spacing and I was almost positive that domino radio button rendering would not do.


There were several things that I knew up front.

1.   Whatever I put up in phase 1 would be wrong.
2.   The wrong stuff specified by #1 needed to look consistant and when the new stuff comes in (likely several iterations), it also would need to be consistent.
3.   I know up front that I hate, hate, hate going back and pasteing in one field after another.

Which lead me to think about the @eval function.   I've been around for for a while and I've never used it.   I also can't remember seeing anyone else using it, so, I thought I would give it a try.


Long story -> short it worked awsome, I was able to store a "template" for the formula of rendering my HTML then evaluate that over and over.

Well, it accomplished the goal, but, the needs were not very universal and the solution, however cool to me, was not very portable.

Soon thereafter I stumbled upon by very own personal addressbook.   Look at all those phone numbers, some of them clearly were imported from outlook, some of them came from add to local addressbook within some companies domain and all of them, across the board were formatted differenly.

I'm a "data"   guy, I can't help myself from wanting a consistent format.  One thing for sure, is that the moment that I draw a line in the sand and state, "this is my format"  I will meet someone in a new country, and the formatting will need to be updated.   But, since I've done it everywhere, I will need to apply the same fix to all the places that I did previously (and don't forget any)

This seemed to me to be another oportunity for my new friend the @eval function.

I started out putting my formula in a Computed for Display field, I did my testing, it all worked fine, I did some tweeking, etc it was a wonderfull thing.

Then, at the view level I thought about selecting all then hitting my homegrown ToolsRefreshSelectedDocs, toolbar icon, but stopped because that will not work.  (or maybe it will, but, I know that the lotusscript compute with form will not work), so, instead, I created a CFD field that would update a profile document that contains the formula.    Profile documents are always there and rockin fast.

So, heres how I did it.

In every phone field I put this formula in the input translation formula.


@Eval( @GetProfileField( "Input";"PhoneTranslation"))

What that does is gets the string of text from the profile document and treats it like a formula and comes back with a result.

Then at the top of the form, I generated a computed for display field (marked as hidden)  It had this formula.

Translate := @GetProfileField( "Input";"PhoneTranslation");
@If( Translate!="";@Return("Set.AlreadyDone");"");
ProfileValue := "
FieldVal := @ThisValue;
WellFormed := \"{+}+{0-9-}{ }{(}+{0-9}{)}+{0-9-}\";
Extention := \"{ }{e}{ }+{0-9}\";
@If(
 @Matches( FieldVal; WellFormed); @Return(FieldVal);
 @Matches( FieldVal; WellFormed +Extention); @Return(FieldVal);
 \"\");
StripFormat := \"+\":\" \":\"(\":\")\":\".\":\"-\":\" \";
NoFmt := @ReplaceSubstring( FieldVal;StripFormat;\"\");
RTNValue := @If(        
                @Left( NoFmt;1) = \"1\" & @Length( NoFmt) = 11;
                        \"+1 (\" +@Middle( NoFmt;1;3) + \")\" + @Middle( NoFmt;4;3) + \"-\" + @Middle( NoFmt;7;4);
                @Left( NoFmt;1) != \"1\" & @Length( NoFmt) = 10;
                        \"+1 (\" +@Middle( NoFmt;0;3) + \")\" + @Middle( NoFmt;3;3) + \"-\" + @Middle( NoFmt;6;4);
                FieldVal);
@return(RTNValue);
";
@SetProfileField( "Input";"PhoneTranslation";ProfileValue);
Translate := @GetProfileField( "Input";"PhoneTranslation");
@If(
        Translate!="";
                @Return("Set.Success");
                @Return("Set.Failed"))


I've got 12 minutes, so, Im gonna be quick about it.

If there is already a profile document stored in the database, then don't do anything, just exit out with the @return function, if that part of the @if statement is evaluated, nothing else after it, in the formula will be evaluated.

Directly after that I set the value for the ProfileValue field, notice that there is an opening quote on the first line, then that statement goes on until the closing quote & semicolon several lines down.

Thats the part that I expect will need to change later, but, I don't know how.   When it does change it will need to change everywhere.
So, I set the value into the profile field in the next line, directly after that I read it back.

Now, I didn't do any testing here, but, I assumed that "SOMETHING" could go wrong.   I'm not sure what could go wrong in my personal addressbook, but, just in case I check the value, then promptly do nothing with the result of my check.

Wow, and me with 2 minutes to spare.

(10)

PermaLink Hiding Column Formulas - Development tip01:11 PM

Most of my work recently has been web based, and the users don't have client access to the databases.  All maintenance and other nondevelopment activity is done over the web.

So, sometime I don't hide HTML based view columns, I just leave them showing so, as I'm developing if I need to look at the raw generated HTML its very easy.

Recently I've had the desire for a "visible sometimes" column, which leads me to this quick post.  If the concept was any more difficult, I would take forever to make the post, then finally quit writing before completion.

On the column properties (beanie tab) use this formula:

@Environment( "ShowHiddenColumns" )!="Yes"

Then create a toolbar button with this formula:

EnvName:="ShowHiddenColumns";
NewVal:=@If(@Environment( EnvName )="Yes";"No";"Yes");
@Environment( EnvName ;NewVal)

The only thing that is missing is refreshing the view, currently, I have to switch to a different view, then back to the one with the "sometimes hidden" column

Bonus tip:
I always label my column headers beginning with "H-" and change the label color to red.  Since this is only seen in then designer its helpful to separate programmatic columns VS display columns.
Bonus tip 2:
For hidden columns that are used to return data (like @implode(fullname:address:city:state:zip;"~")), the column number is important, concider putting it in the label like this:

H-Column 5-Lookup

Also concider puting the lookup values in column 1 if your not sorting on it.  That allows your lookup views to also be used and customized for developer maintenance too.

Anyone still reading?


(58)

Powered By :

BlogSphere

Join The WebLog Revolution at BlogSphere.net

Dwight Pic
Hot Links
These are my heavy hitters
MSDN DHTML Objects
MSDN JScript

Contact Me
Left Block 3
Monthly Archive
Todays Referrers
RSS News Feed RSS Comments Feed Geo URL Blog Admin OpenNTF BlogSphere