Any blog entry that includes usage instructions of use in rare circumstances and with caution deserves a link. K. Scott Allen's sample code / wrapper around CreateProcessAsUser
[Listening to: Iron Maiden - Caught Somewhere in Time]
Friday, October 29, 2004
CreateProcessAsUser
Posted by
BigEasy
at
10/29/2004 08:47:00 AM
0
comments
Tuesday, October 26, 2004
Easily Creating a StrongNameMembershipCondition for an Assembly
Another gem from Shawn Farkas: Easily Creating a StrongNameMembershipCondition for an Assembly
[Listening to: Electric Light Orchestra - Turn to Stone]
Posted by
BigEasy
at
10/26/2004 03:41:00 PM
0
comments
Creating an AppDomain with limited permissions
Shawn Farkas has to be on my top 10 list of bloggers. His blog entries and snippets are awesome and (eerily enough) tend to be right along the lines of stuff that I'm going to need. How does he know what I'm doing? Hey Shawn, that isn't you hanging around in the bushes outside my office window is it?
Without further ado: Creating an AppDomain with limited permissions.
[Listening to: Eartha Kitt - Where is my man]
Posted by
BigEasy
at
10/26/2004 03:39:00 PM
0
comments
More Performance Tidbits for library writers
More Performance Tidbits for library writers from the performance guru Rico "measure first" Mariani.
At some point either they'll figure out a way to really profile in a VPC image or I'll have to knuckle under and install VS2005 on my host PC. 'Til then, my head is firmly in the sand.
[Listening to: Alice in Chains - Junkhead]
Posted by
BigEasy
at
10/26/2004 10:22:00 AM
0
comments
Monday, October 25, 2004
Getting the Current Permissions in a Named Permission Set
Shawn Farkas posted a snippet on Getting the Current Permissions in a Named Permission Set. I like snippets. Snippets are good. Long live snippets.
Does it make sense for me to define my own Named Permission Set for my service? Don't know yet. Haven't spent enough time looking.
[Listening to: Kittie - In Winter]
Posted by
BigEasy
at
10/25/2004 09:38:00 AM
0
comments
Friday, October 22, 2004
Programatically changing file permissions
I'm back to implementing some permission related unit tests that I balked at earlier.
It took me a bit of time to find how to remove all permissions from a file. Since I don't want to have to go through this again I'll post it here.
Basically I'm pulling what I found in Keith Brown's absolute must read wiki: The .NET Developer's Guide to Windows Security in How to program with SIDs into a class.
I implemented it in a typical Resource Acquisition Is Initialization manner using IDispose so that I know I'll restore the permissions to their original after my tests are done.
Here's the class (a little light on error checking for brevity):
class ApplySecuritySettingsToFile : IDisposable
{
#region Private Members
private FileSystemAccessRule m_AccessRule = null;
private FileInfo m_FileInfo = null;
#endregion
#region Constructor
public ApplySecuritySettingsToFile (string fileName,
FileSystemAccessRule accessRule)
{
if (fileName == null && accessRule == null)
return;
m_FileInfo = new FileInfo (fileName);
m_AccessRule = accessRule;
FileSecurity sd = m_FileInfo.GetAccessControl ();
sd.AddAccessRule (m_AccessRule);
m_FileInfo.SetAccessControl (sd);
}
#endregion
#region Dispose pattern
private bool m_bIsDisposed = false;
~ApplySecuritySettingsToFile ()
{
Dispose ();
}
public void Dispose ()
{
if (!m_bIsDisposed)
{
if (m_FileInfo != null && m_AccessRule != null)
{
FileSecurity sd =
m_FileInfo.GetAccessControl ();
sd.RemoveAccessRule (m_AccessRule);
m_FileInfo.SetAccessControl (sd);
}
GC.SuppressFinalize (this);
m_bIsDisposed = true;
}
}
#endregion
}And here's how you use it to Deny FullControl (i.e. remove all permissions) to file C:\temp\temp.txt for the BUILTIN\users group:
using (new ApplySecuritySettingsToFile (@"C:\temp\temp.txt",
new FileSystemAccessRule (
new SecurityIdentifier (
WellKnownSidType.BuiltinUsersSid,
null),
FileSystemRights.FullControl,
AccessControlType.Deny)
)
)
{
// You (and everyone else for that matter) now have
// no permissions whatsoever to C:\temp\temp.txt
}You could just as easily add permissions using AccessControlType.Allow.
Hope it helps.
[Listening to: Marilyn Manson - Mother Inferior Got Her Gunn]
Posted by
BigEasy
at
10/22/2004 06:38:00 PM
0
comments
Thursday, October 21, 2004
Boost XmlSerializer usability and performance by using strongly-typed serializers
A short but sweet bit on how to Boost XmlSerializer usability and performance by using strongly-typed serializers from Daniel Cazzulino of Mvp.Xml fame.
[Listening to: Delerium featuring Sarah McLachLan - Silence]
Posted by
BigEasy
at
10/21/2004 03:30:00 PM
0
comments
Monday, October 18, 2004
Number Formatting in .NET
An overview of Number Formatting in .NET via Kit George of the BCL Team.
I too have spent far too much time looking for the right format string on MSDN. This is a step in the right direction.
[Listening to: Rage Against the Machine - The Ghost of Tom Joad]
Posted by
BigEasy
at
10/18/2004 09:00:00 AM
0
comments
Thursday, October 14, 2004
Nifty VS2003 tips for breakpoints and the "Find" combo box
Roy Osherove shows a few really nifty tricks: Advanced debugging tips and stuff you never knew about the "Find" combo box
[Listening to: Faster Pussycat - Babylon]
Posted by
BigEasy
at
10/14/2004 09:59:00 AM
0
comments
Programmatic .NET ACL Definitions
Another awesome security related code tidbit from Michael Willers:
TaskDriven Working with ACLs on files.
I'm already subscribed to his feed, but I somehow managed to miss this gem when it came out fresh. Much thanks to Jeff Newsom from Thinking Out Loud for reposting the link that actually made it past my forehead.
[Listening to: Soundgarden - Pretty Noose]
Posted by
BigEasy
at
10/14/2004 08:43:00 AM
0
comments