Posts

Showing posts from October, 2014

How do I create a internet proxy for an account that does not have internet access?

Image
The development domain for my current client does not given its account internet access. Thi can be overcome in Powershell scripts as follows: $user = " MyDomain\MyAccount " $password = ConvertTo-SecureString –String " password " –AsPlainText -Force $cred = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $user, $password [System.Net.WebRequest]::DefaultWebProxy.Credentials = $cred but it becomes a problem is the current user credential is used do download files or if the proxy server blocks certain actions. A fantastic tool to resolve this problem is  cntlm , which allows you create a local internet proxy. The configuration (simplified) is as follows: 1. Download and install the software. 2. Set the username and domain in the .ini file. Remove the password setting 3. Type the Url of internet proxy.pac file in a browser and get proxy urls. Add these urls to the config file and remove the 'sample' entries. 4. Ex

SharePoint: How do I find out (quickly) if my server has a Kerberos ticket?

A new SharePoint project introduced the prospect of the dreaded 'double hop' problem and the team was looking at ways to resolve the issue. Naturally, Kerberos (and delegation) was the natural solution. However, we were not sure if the Farm and Servers had Kerberos enabled. A quick one word line command resolved the problem:  klink . This command displays a list of currently cached Kerberos tickets.

PowerShell: How do I know what methods a commandlet has?

There is nothing more frustrating than trying to find out what methods are exposed in a commandlet that you are using. Fortunately, there is a commandlet to expose commandlets: Get-Member So, if I wanted to know what properties / methods are exposed in Get-SPOSite, I would execute the following: Get-SPOSite | Get-Member

MVC4: Why cant I resolve the WebSecurity class?

While trying to create a two step password reset page, I struggled to find the required reference for the WebSecurity class (to generate the ResetToken). The solution is to add a reference to C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v2.0\Assemblies\WebMatrix.WebData.dll

C#: Compare two text files (quickly)

I am busy writing a windows service that is send emails. However, I need to track the emails that have already been sent to that people. The current solution writes the audit to a text file (SQL Server is not an option). I hit a major performance problem when processing a 30000 row file - I had already processed 5000 records and the iterative (line by line) approach was just not working. I put my SQL hat on and looked for a C# equivalent of the  EXCEPT  command. Enter  Googles Diff Match Patch . It has a simple C# class that performs incredibly well. I now has a very simple and fast solution. Here is the code: using DiffMatchPatch; string source; string target; // Load the source file into a string using (StreamReader  reader = new StreamReader(MYSOURCEFILE)) {   source = reader.ReadToEnd(); } // Load the comparison file into a string using (StreamReader  reader = new StreamReader(MYTARGETFILE)) {   target = reader.ReadToEnd(); } // Instantiate the class v