Just some weeks ago I ended up in a situation where I needed to get a user SID (Security Identifier). I found a good script on the net that I just needed to modify a little.
Just log in as the user you need SID for and run this script:
"strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objAccount = objWMIService.Get _
("Win32_UserAccount.Name='xxxx',Domain='yyy'")
Wscript.Echo objAccount.SID"
replace xxxx with you user name and domain yyy.
Depending on your settings you'll get the output as alertbox or in the cmd.
(verified on windows server 2003)
Wednesday, October 17, 2012
Sunday, August 12, 2012
System integration using dropbox
I've been using dropbox for some time and I think it's terrific for managing all kind of information accross your devices. It's so easy.
It just occured to me that dropbox could be used for integration purposes. After all it's 'just' an engine that integrate between all devices belonging to your account.
Dropbox sync folders on the devices connected to the same dropbox account. I don't think it's possible to have more than one account for each device.
There's no master. For instance if you delete a file from any device it'll propagate to all devices. So what kind of integration patterns could one achive with this tool?
The most obvious one is the point to point channel pattern.
(Ther're quite a lot of integration scenarios I've encountered where you need to exchange information between a windows server and a linux server. And I think that this technique could be usefull for such a scenario)
It should also be possible to broadcast information letting one publisher act as the master for the information and have 1 to many 'subscribers' that passively receive the information. I guess that if you don't need it to be transactional that one could use the dropbox service for this purpose.
(I won't be a true publish - subscribe channel as there's no way for the subscribers to filter the information. They'll get all of it so it's more like a broadcast.)
So let's test how it works.
(To create the servers I'm using windows azure)
1 - Create some dropbox account at: https://www.dropbox.com/login?lhs_type=anywhere
2 - Create the servers from windows azure management console.
Just choose virtual machines on the left meny -> NEW -> choose from templates
(I choosed a windows 2008 os and the 'SUSE' enterprise linux distribution)
3 - Install the client software on the servers between witch you want to sync information. For windows it's an installer and for linux you should follow the instructions provided here:
https://www.dropbox.com/install?os=lnx
(you can get an rdp file from the management console just clicking on the 'connect' button in the windows azure management console. For linux you need to use some SSH client. I used the putty client)
4 - I wrote a very simple windowsform application to post some information from the windows server to the linux server. All it does is take some text, put it on the dropbox sync folder on disk (on the windos server) and write out some logging. The rest of the work is left to dropbox :)
This is the code for the form events:
"using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace ClientPoster
{
public partial class Form1 : Form
{
String syncPath = System.Configuration.ConfigurationSettings.AppSettings.Get("syncPath");
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
addMessageToLogWindow("try write to disk");
writeToDisk(textToPost.Text);
addMessageToLogWindow("write to disk successfull");
}
catch (Exception wDiskExp) {
addMessageToLogWindow("Error writing to disk: ");
addMessageToLogWindow(wDiskExp.Message);
addMessageToLogWindow(wDiskExp.Source);
}
}
private Boolean writeToDisk(string text) {
try
{
StreamWriter mStreamWriter = new StreamWriter(syncPath + Guid.NewGuid().ToString() + ".txt", false, Encoding.Default);
mStreamWriter.Write(text);
mStreamWriter.Dispose();
mStreamWriter.Close();
return true;
}
catch (Exception e) {
throw e;
}
}
private void addMessageToLogWindow(string message) {
textLog.Text += System.Environment.NewLine + DateTime.Now.ToShortTimeString() +
": " + message;
}
}
}"
5 - Finally I run a debug of the form client from visual studio to test it all.
See screen dumps below to follow the workflow from the windows server to the linux server.
conclusion:
I'm quite amazed on how easy and fast this was to implement. I guess there're a lot of options to communicate between a windows to a linux server but my own experience is that it's not so obvious. If you use sftp you need to create the accounts and make sure all ports are opened. With dropbox you (normaly) just need servers wired to the internet. And most of the servers are today, even the production servers (as you want to keep them up to date). Dropbox uses port 80 and 443 (https). It uses SSL to transfer your data so security should be decent. If one needs additional security I would encrypt the data.
I'm maybe completely wrong here but isn't this a viable way to transfer information between servers then it's not super critical (then you will want to use some transactional queue mechanism) instead of struggling with sftp / file shares (ie samba) ... ?
Subscribe to:
Posts (Atom)