<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Stephen&#039;s Space on the Web</title>
	<atom:link href="http://www.stephenjc.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stephenjc.com</link>
	<description>This is my space on the internet. I got tired of writing scripts and/or code and then losing them.  The code may be 100% mine or I might have found it on the internet.</description>
	<lastBuildDate>Tue, 13 Mar 2012 16:30:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>&#8220;Preview&#8221; open old files every time I&#8217;m trying to open a new file</title>
		<link>http://www.stephenjc.com/2012/03/13/preview-open-old-files-every-time-im-trying-to-open-a-new-file/</link>
		<comments>http://www.stephenjc.com/2012/03/13/preview-open-old-files-every-time-im-trying-to-open-a-new-file/#comments</comments>
		<pubDate>Tue, 13 Mar 2012 16:30:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.stephenjc.com/?p=1510</guid>
		<description><![CDATA[defaults write com.apple.Preview NSQuitAlwaysKeepsWindows -bool false http://forums.macrumors.com/showthread.php?t=1203457]]></description>
			<content:encoded><![CDATA[<p>defaults write com.apple.Preview NSQuitAlwaysKeepsWindows -bool false</p>
<p>http://forums.macrumors.com/showthread.php?t=1203457</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stephenjc.com/2012/03/13/preview-open-old-files-every-time-im-trying-to-open-a-new-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Regular Expression Builder</title>
		<link>http://www.stephenjc.com/2011/11/02/regular-expression-builder/</link>
		<comments>http://www.stephenjc.com/2011/11/02/regular-expression-builder/#comments</comments>
		<pubDate>Wed, 02 Nov 2011 11:49:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[regexp]]></category>

		<guid isPermaLink="false">http://www.stephenjc.com/?p=1408</guid>
		<description><![CDATA[I alway had a hard time wrapping my head around RegExp. I know how useful, but I was having a mental block. This tool make is 100% easier to use. Its a free RegExp builder in Air. http://gskinner.com/RegExr/desktop/]]></description>
			<content:encoded><![CDATA[<p>I alway had a hard time wrapping my head around RegExp. I know how useful, but I was having a mental block.</p>
<p>This tool make is 100% easier to use. Its a free RegExp builder in Air.</p>
<p>http://gskinner.com/RegExr/desktop/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stephenjc.com/2011/11/02/regular-expression-builder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spideroak</title>
		<link>http://www.stephenjc.com/2011/08/24/spideroak/</link>
		<comments>http://www.stephenjc.com/2011/08/24/spideroak/#comments</comments>
		<pubDate>Wed, 24 Aug 2011 12:21:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.stephenjc.com/?p=917</guid>
		<description><![CDATA[I have been playing with Spideroak and I like the idea that they have a share nothing approach. If you want to sign up use this link so I can get some free space. https://spideroak.com/download/referral/847969fa8588154fc59282104ae415da]]></description>
			<content:encoded><![CDATA[<p>I have been playing with Spideroak and I like the idea that they have a share nothing approach.</p>
<p>If you want to sign up use this link so I can get some free space.</p>
<p><a href="https://spideroak.com/download/referral/847969fa8588154fc59282104ae415da" target="_blank">https://spideroak.com/download/referral/847969fa8588154fc59282104ae415da</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.stephenjc.com/2011/08/24/spideroak/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sophos Duplicate IDs</title>
		<link>http://www.stephenjc.com/2011/08/23/sophos-duplicate-ids/</link>
		<comments>http://www.stephenjc.com/2011/08/23/sophos-duplicate-ids/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 14:53:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[duplicate]]></category>
		<category><![CDATA[sophos]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.stephenjc.com/?p=910</guid>
		<description><![CDATA[I found my self in a large environment where someone decided to deploy an image with Sophos installed. This resulted in all the computers being seen as 1 single computer in the Sophos Enterprise Console. This caused me to write the following scripts. sophosFindDuplicate.pl scan the IIS logs looking for duplicate GUIDs from computer. It [...]]]></description>
			<content:encoded><![CDATA[<p>I found my self in a large environment where someone decided to deploy an image with Sophos installed. This resulted in all the computers being seen as 1 single computer in the Sophos Enterprise Console.</p>
<p>This caused me to write the following scripts. sophosFindDuplicate.pl scan the IIS logs looking for duplicate GUIDs from computer. It will output the IPs of the machines. This command will let you remotely fix the machines.(Remeber to whitelist psexec in Sophos)</p>
<pre class="brush:text">psexec @hosts.txt -u domain\user -p password -c batchfile.bat</pre>
<p>sophosFixDuplicate.cmd</p>
<pre class="brush:text">@echo off
net stop "Sophos Message Router"
net stop "Sophos Agent"
net stop "Sophos AutoUpdate Service"

echo y|del "C:\Program Files\Sophos\AutoUpdate\machine_ID.txt"
echo y|del "C:\ProgramData\Sophos\AutoUpdate\machine_ID.txt"

reg delete "HKLM\Software\Sophos\Messaging System\Router\Private" /v pkc /f
reg delete "HKLM\Software\Sophos\Messaging System\Router\Private" /v pkp /f

reg delete "HKLM\Software\Sophos\Remote Management System\ManagementAgent\Private" /v pkc /f
reg delete "HKLM\Software\Sophos\Remote Management System\ManagementAgent\Private" /v pkp /f

reg delete "HKLM\Software\Wow6432Node\Sophos\Messaging System\Router\Private" /v pkc /f
reg delete "HKLM\Software\Wow6432Node\Sophos\Messaging System\Router\Private" /v pkp /f

reg delete "HKLM\Software\Wow6432Node\Sophos\Remote Management System\ManagementAgent\Private" /v pkc /f
reg delete "HKLM\Software\Wow6432Node\Sophos\Remote Management System\ManagementAgent\Private" /v pkp /f

net start "Sophos Message Router"
net start "Sophos Agent"
net start "Sophos AutoUpdate Service"</pre>
<p>sophosFindDuplicate.pl</p>
<pre class="brush:perl">#Stephen
#Check for Duplicates
use Data::Dumper;

$file = "\\\\sophos-c108-01\\W3SVC1\\u_ex110822.log";
my %hash = ();
my %hDup = ();

open FILE, $file or die $!;

while () {
  @data = ($_ =~ /(\b143\.55\.\d{1,3}\.\d{1,3}\b).*?(\b143\.55\.\d{1,3}\.\d{1,3}\b).*?(\{{0,1}[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\}{0,1})/);
	#print $data[0] . "\n";
	if ((exists $hash{$data[2]}) &amp;&amp; ($hash{$data[2]} ne $data[1]))
	{
		if(not exists $hDup{$data[1]})
		{
			print $data[1] . "\n";
			$hDup{$data[1]} = $data[1];
		}
	}
	else
	{
		$hash{$data[2]} = $data[1];
	}
}

close(FILE);</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.stephenjc.com/2011/08/23/sophos-duplicate-ids/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows 7 RDP Hack</title>
		<link>http://www.stephenjc.com/2011/06/28/windows-7-rdp-hack/</link>
		<comments>http://www.stephenjc.com/2011/06/28/windows-7-rdp-hack/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 11:57:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[7]]></category>
		<category><![CDATA[rdp]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[windows 7]]></category>

		<guid isPermaLink="false">http://www.stephenjc.com/?p=568</guid>
		<description><![CDATA[This hack is two fold. If you have Home or Home Premium which does not include RDP, this will let you remote into your computer. Also, if you want RDP to behave more like a real terminal server where you can have concurrent logons. http://andrewblock.net/2010/02/23/enable-remote-desktop-on-windows-7-home-premium-64-32-bit]]></description>
			<content:encoded><![CDATA[<p>This hack is two fold. If you have Home or Home Premium which does not include RDP, this will let you remote into your computer. Also, if you want RDP to behave more like a real terminal server where you can have concurrent logons.</p>
<p><a href="http://andrewblock.net/2010/02/23/enable-remote-desktop-on-windows-7-home-premium-64-32-bit">http://andrewblock.net/2010/02/23/enable-remote-desktop-on-windows-7-home-premium-64-32-bit</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.stephenjc.com/2011/06/28/windows-7-rdp-hack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adobe Air Mobile</title>
		<link>http://www.stephenjc.com/2011/06/24/adobe-air-mobile/</link>
		<comments>http://www.stephenjc.com/2011/06/24/adobe-air-mobile/#comments</comments>
		<pubDate>Fri, 24 Jun 2011 13:58:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[action]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.stephenjc.com/?p=378</guid>
		<description><![CDATA[I wrote my first Adobe Air Mobile app yesterday. It took me a couple of hours to wrap my head around action script, but I think we have come to terms. I will start posting action script code soon.]]></description>
			<content:encoded><![CDATA[<p>I wrote my first Adobe Air Mobile app yesterday. It took me a couple of hours to wrap my head around action script, but I think we have come to terms. </p>
<p>I will start posting action script code soon. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.stephenjc.com/2011/06/24/adobe-air-mobile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IMAP Copy to local file.</title>
		<link>http://www.stephenjc.com/2011/05/18/imap-copy-to-local-file/</link>
		<comments>http://www.stephenjc.com/2011/05/18/imap-copy-to-local-file/#comments</comments>
		<pubDate>Wed, 18 May 2011 16:50:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.stephenjc.com/?p=371</guid>
		<description><![CDATA[I had a mail server that only supported IMAP, but their webmail interface is horrible. So I decided to write a small script to grab the email from the imap server and save it locally. In my case the local directory is the mail directory in cpanel so I can use gmail to grab the [...]]]></description>
			<content:encoded><![CDATA[<p>I had a mail server that only supported IMAP, but their webmail interface is horrible. So I decided to write a small script to grab the email from the imap server and save it locally. In my case the local directory is the mail directory in cpanel so I can use gmail to grab the emails via POP3 to use gmail. The mail flow is:</p>
<pre class="brush:xml">IMAP SERVER -&gt; SCRIPT -&gt; LOCAL POP3 -&gt; GMAIL</pre>
<p>imapscript</p>
<pre class="brush:php">
<?php
#stephen
#imap mail copy script

echo '<?xml version="1.0" encoding="UTF-8" ?><Module><ModulePrefs title="Remote Imap Collector" /><Content type="html"> <![CDATA[ ';
echo "starting\n";
echo "writing lock\n";
$lockfile = "asaimapsync.lock";

if (file_exists($lockfile))
{
    die("Lock file exists.");
}
else
{
$ourFileHandle = fopen($lockfile, 'w') or die("can't open file");
fclose($ourFileHandle);
}

#open mail connection
$srcstream = imap_open("{imap.mailserver.local:143/notls}inbox", "uid", "password");

#check mail box
$MC = imap_check($srcstream);
$result = imap_fetch_overview($srcstream,"1:{$MC->Nmsgs}",0);
foreach ($result as $overview)
{
	echo "$overview->subject\n";
	$mailfile = tempnam("/home/mth/mail/stephenjc.com/asa/cur/","EMAIL-");
	$message =  imap_fetchbody($srcstream,$overview->uid,"",FT_UID);
	$localmail = fopen($mailfile, "w");
	fwrite($localmail,$message);
	fclose($localmail);
	imap_mail_move($srcstream,$overview->msgno,'Forwarded'); 

}

imap_expunge($srcstream);
imap_close($srcstream);
echo "deleteing lock\n";
unlink($lockfile);

echo '     ]]&gt; </Content></Module>';
?>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.stephenjc.com/2011/05/18/imap-copy-to-local-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ReadyNAS Google Authenticator</title>
		<link>http://www.stephenjc.com/2011/04/18/readynas-google-authenticator/</link>
		<comments>http://www.stephenjc.com/2011/04/18/readynas-google-authenticator/#comments</comments>
		<pubDate>Mon, 18 Apr 2011 02:53:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[authenticator]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[netgear]]></category>
		<category><![CDATA[readynas]]></category>
		<category><![CDATA[two factor]]></category>

		<guid isPermaLink="false">http://www.stephenjc.com/?p=137</guid>
		<description><![CDATA[I just finished configuration Google two-factor authentication on my ReadyNAS for ssh authentication. It works well so far. You need to install the Root SSH Add-on from the forums so you can ssh into your readynas. apt-get update apt-get install mercurial make gcc apt-utils libc6-dev gdb libtag1-dev uuid-dev libpam0g-dev The just follow these instructions http://www.mnxsolutions.com/security/two-factor-ssh-with-google-authenticator.html]]></description>
			<content:encoded><![CDATA[<p>I just finished configuration Google two-factor authentication on my ReadyNAS for ssh authentication. It works well so far.</p>
<p>You need to install the Root SSH Add-on from the forums so you can ssh into your readynas.</p>
<p><code><br />
apt-get update<br />
apt-get install mercurial make gcc apt-utils libc6-dev  gdb libtag1-dev uuid-dev libpam0g-dev<br />
</code><br />
The just follow these instructions<br />
<a href="http://www.mnxsolutions.com/security/two-factor-ssh-with-google-authenticator.html">http://www.mnxsolutions.com/security/two-factor-ssh-with-google-authenticator.htm</a>l</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stephenjc.com/2011/04/18/readynas-google-authenticator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Macintosh Logon Scripts</title>
		<link>http://www.stephenjc.com/2011/02/09/macintosh-logon-scripts/</link>
		<comments>http://www.stephenjc.com/2011/02/09/macintosh-logon-scripts/#comments</comments>
		<pubDate>Wed, 09 Feb 2011 04:03:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[logon]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[macintosh]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.stephenjc.com/?p=159</guid>
		<description><![CDATA[Here is a set of Mac logon scripts I wrote for a Windows/AD environment. There are a set of plist files that launch perl scripts and different stages. The logon scripts are local and self-update from the sysvol directory. edu.fitsuny.mac_logon_init.plist Label edu.fitsuny.edu.mac_system_logon ProgramArguments /etc/etsscripts/mac_logon_init.pl RunAtLoad edu.fitsuny.mac_user_logon.plist Label edu.fitsuny.mac_user_logon ProgramArguments /etc/etsscripts/mac_user_logon.pl RunAtLoad mac_system_logon.pl #!/usr/bin/perl -l #Please [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a set of Mac logon scripts I wrote for a Windows/AD environment. There are a set of plist files that launch perl scripts and different stages. The logon scripts are local and self-update from the sysvol directory.</p>
<p>edu.fitsuny.mac_logon_init.plist</p>
<pre class="brush:xml">
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>edu.fitsuny.edu.mac_system_logon</string>
	<key>ProgramArguments</key>
	<array>
		<string>/etc/etsscripts/mac_logon_init.pl</string>
	</array>
	<key>RunAtLoad</key>
<true/>
</dict>
</plist>
</pre>
<p>edu.fitsuny.mac_user_logon.plist</p>
<pre class="brush:xml">
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>edu.fitsuny.mac_user_logon</string>
	<key>ProgramArguments</key>
	<array>
		<string>/etc/etsscripts/mac_user_logon.pl</string>
	</array>
	<key>RunAtLoad</key>
<true/>
</dict>
</plist>
</pre>
<p>mac_system_logon.pl</p>
<pre class="brush:perl">
#!/usr/bin/perl -l
#Please make your function a sub and then call it.
#FYI: an error here will break the entire script
open (LOG, '>>/tmp/logon_system.txt');
print LOG "Running System Hook V1.0 \n";

#remember with admitmac the username might be @fitsuny.edu
$username = $ARGV[0];

#updates the loader.pl just in case we make changes there.
updateloader();

sub updateloader
{
	system('smbclient //fit-c108-01/netlogon Password -U mac_logon -c \'get \\Macintosh\\installer\\mac_logon_init.pl /etc/etsscripts/mac_logon_init.pl\'');
	if ($? != 0)
	{ #try dc 1
		system('smbclient //fit-c108-02/netlogon Password -U mac_logon -c \'get \\Macintosh\\installer\\mac_logon_init.pl /etc/etsscripts/mac_logon_init.pl\'');
	if ($? != 0)
	{# failed again print error
		print LOG 'SYSTEM: Cannot download loader.pl script\n';
	}

	chmod(0755,'/etc/etsscripts/mac_logon_init.pl');
}
}
</pre>
<pre class="brush:perl">
#!/usr/bin/perl -l
#Please make your process a sub and then call it.
#FYI: an error here will break the entire script
#This runs at user the user profie is in ~/ || mkdir() does not understand ~/
#
open (LOG, '>/tmp/logon_user.txt');
print LOG "Running User Hook V1.0 \n";

#remember with admitmac the username might be @fitsuny.edu

my $username = $ENV{'USER'};
my $profiledir = $ENV{'HOME'};

if ( $username =~ m/[@]/ )
{
	my @tmpusername = split(/@/,$username);
        $username = $tmpusername[0];
}
print LOG "USER: username " . $username . "\n";

#system test script, an example of giving the user a GUI popup box from a perl script
#system('osascript -l AppleScript -e \'tell Application "Finder" to display dialog "Call Frank"\'');

#get Prirole once
$usertype = get_prirole();
print LOG "USER: using prirole " . $usertype . "\n";

disable_dsstore();
mount_winfs();
#emgmesg();

#their profile is in Users which means they are not using admit mac
if ($profiledir =~ m/\/Users\//)
{
	mount_stanNDrive();
}

sub disable_dsstore
{
	#this will disable .DS_STORE on network volumes
	#This will stop some weird bugs

	system('defaults write com.apple.desktopservices DSDontWriteNetworkStores true');
}

sub mount_stanNDrive
{
	use Net::LDAP;

	$ldap = Net::LDAP->new ('fit-c108-01') or die "$@";
	$ad = $ldap->bind('cn=ldapsearch,ou=fitusers,dc=fitsuny,dc=edu', password => 'password);
	$ad = $ldap->search (base => 'ou=FitUsers,dc=fitsuny,dc=edu',
        	                filter => "(&#038;(cn=" . $username . "))",
        	                attrs => ['homeDirectory'],
        	                );

	$ad->code &#038;&#038; die $ad->error;

	$winHomeDir =  $ad->entry->get_value('homeDirectory');
	$ad = $ldap->unbind;

	$winHomeDir =~ s/\\\\/smb:\/\//;
	$winHomeDir =~ s/\\/\//g;

	$osascript = qq[mount volume "$winHomeDir"];
	system( "osascript -e '$osascript'");

}
sub mount_winfs
{
	#check to make sure mount exists
	#check pri-role to see what server they are on

	my $pilot_user  = shift;

	my $servershare;
	$servershare = 'fs-c108-03/student_home$/'  if ifmember($username,'students') ;
	$servershare = 'fs-c108-04/faculty_home$/'  if ifmember($username,'faculty')  ;

	return unless $servershare; # Don't attempt mount if no Y: drive for user

	my $winfs_path = '//' . $servershare . $username;
	$mntfolder = $ENV{'HOME'} . '/Desktop/' . $username . '_CAMPUSFILES';

	print LOG $servershare . "\n";
	print LOG $mntfolder . "\n";
	system('mkdir ' . $mntfolder);
    	system('mount_smbfs -o nobrowse ' . $winfs_path . ' ' . $mntfolder);

	#get list of mounts
	$mountlist = `mount`;
	if ($mountlist =~ m/CAMPUSFILES/ix)
	{# Successful mount
	}
	else
	{# Match attempt failed
		system('rm -dfr ' . $mntfolder);
	}

}

sub get_prirole
{
	my $ldapsearch = qq[ldapsearch -h ldap.fitsuny.edu -b "dc=fitsuny,dc=edu" -LLL -x "(uid=$username)" fitprirole];
	my $usertype = `$ldapsearch`;

	$usertype =~ s/^.*fitprirole:\s+(.*)$/$1/s;

	return $usertype;
}

sub ifmember
{
#does not do nested groups.

	$_username = shift;
	$_group = shift;
	use Net::LDAP;
	$ldap = Net::LDAP->new ('fit-c108-01') or die "$@";
	$ad = $ldap->bind('cn=ldapsearch,ou=fitusers,dc=fitsuny,dc=edu', password => 'password');
	$ad = $ldap->search (base =>'ou=FiTUsers,dc=fitsuny,dc=edu',
				filter => "(&#038;(cn=" . $_username . ")(memberof=cn=" . $_group . ",ou=fitgroups,dc=fitsuny,dc=edu))",
				#attrs => ['memberOf'],
				);
	$ad->code &#038;&#038; $ad->error;

	return $ad->count();

}

sub emgmesg
{
$message = "LOGIN TO MyFIT TO REGISTER FOR EMERGENCY MESSAGE NOTIFICATIONS
Get timely announcements in the event of a campus emergency or a weather-related closure of the college via text message, email, or voicemail.

Would you like to sign up now?";

#icons Types (stop, note, caution)
$icon = 'note';

#button types (ok, yesno)
$buttons = 'yesno';

#action
$action = 'http://myfit.fitnyc.edu';

if($icon eq 'stop')
	{
		$ic = '0';
	}
	elsif($icon eq 'note')
	{
		$ic = '1';
	}
	elsif($icon eq 'caution')
	{
		$ic = '2';
	}

	if($buttons eq 'ok')
	{
		$bu = '{"OK"}';
	}
	elsif($buttons eq 'yesno')
	{
		$bu = '{"YES","NO"}';
	}

	#mac way
	$result = `/usr/bin/osascript <<-EOF

    tell application "System Events"
        activate
        display dialog "$message" buttons $bu with icon $ic
    end tell

EOF`;

chomp($result);
if (($buttons eq 'yesno') &#038;&#038; ($result eq 'button returned:YES'))
{
	system('open ' . $action);
}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.stephenjc.com/2011/02/09/macintosh-logon-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Knowledgetree Metadata Perl</title>
		<link>http://www.stephenjc.com/2011/02/03/knowledgetree-metadata-perl/</link>
		<comments>http://www.stephenjc.com/2011/02/03/knowledgetree-metadata-perl/#comments</comments>
		<pubDate>Thu, 03 Feb 2011 02:25:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[knowledgetree]]></category>
		<category><![CDATA[metadata]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://www.stephenjc.com/?p=128</guid>
		<description><![CDATA[Knowledgetree metadata has been a pain to interface with. Below is an example of posting metadata to Knowledgetree document. Sending SOAP::Data->type(&#8216;xml&#8217; => $xml) will populate the Date on Document and Notes. I am in the process of incorporating it into my ktdrop.pl script. It is true that you cannot send an array via a HTTP [...]]]></description>
			<content:encoded><![CDATA[<p>Knowledgetree metadata has been a pain to interface with. Below is an example of posting metadata to Knowledgetree document. Sending SOAP::Data->type(&#8216;xml&#8217; => $xml) will populate the Date on Document and Notes. I am in the process of incorporating it into my <a href="/2010/02/19/knowledgetree-command-line-drop-box-in-perl/">ktdrop.pl script</a>. It is true that you cannot send an array via a HTTP post as said in some forums, but in SOAP there is an array.</p>
<pre class="brush:perl">
$xml = '	<metadata xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="ns4:kt_metadata_fieldset[1]" SOAP-ENC:offset="[0]">
<fieldset xsi:type="ns4:kt_metadata_fieldset">
<fieldset xsi:type="xsd:string">General Information</fieldset>

				<fields xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="ns4:kt_metadata_field[5]" SOAP-ENC:offset="[0]">
				<field xsi:type="ns4:kt_metadata_field">
					<name xsi:type="xsd:string">Date On Document</name><value xsi:type="xsd:string">'.$docdate.'</value>
				</field>
				<field xsi:type="ns4:kt_metadata_field">
					<name xsi:type="xsd:string">Notes</name><value xsi:type="xsd:string">'.$docnote.'</value>
				</field>
				</fields>
			</fieldset>

		</metadata>';
$r = $session->add_document_with_metadata($ktsessionid,$dropboxid,$uploadRes->{name},$uploadRes->{name},$ktDocumenttype,$uploadRes->{filename}, SOAP::Data->type('xml' => $xml), '' );
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.stephenjc.com/2011/02/03/knowledgetree-metadata-perl/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 6.765 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-03-13 16:31:31 -->
<!-- Compression = gzip -->
