WindowsIdentity.Impersonate(IntPtr.Zero)
like this:
BryansGeekSpeak
Half finished documentation, scripts and other scraps from my work related projects.
Friday, August 19, 2016
SharePoint custom C# code - impersonate the app pool account
Friday, April 10, 2015
Node.js web app experiments
- AngularJS for the client UI/UX. To be deployed to Azure webapp hosting or maybe at some point turned into a phone app using something like Cordova
- ExpressJS for the Data Access Layer. The whole thing is just a collection of JSON web services so its super easy to consume from javascript. This just gets deployed to Azure as another stand alone website that the client app makes calls to.
- PouchDB for the backend database. And also for the sweet client API which I'm using in the DAL project. Since PouchDB is 100% compatible with CouchDB I can just point the client to something like Couchbase when I'm ready to go "live" and get free DB hosting
Friday, December 26, 2014
Coldfusion 11 Java Keytool Import Cert Command
Doing an upgrade of coldfusion from CFMX 6.1 to CF11 and completely forgot how to import/trust external SSL certs (for consuming web services).
- hit the web service WSDL url, confirm it works over HTTPS, and download the base64 version of the cert from your browser
- copy the cert to the coldfusion server (the default path for java cacert keyfile is here: C:\ColdFusion11\jre\lib\security)
- open a command prompt (run as administrator) and execute the command
- Restart coldfusion
note that when you try to add an HTTPS web service with an untrusted SSL cert from the CF Admin you get a generic "Cant read WSDL" error. Not super helpful, but every time I get that message it ends up being either this SSL cert trust issue or that my web service requires windows authentication (CF 11 does not support kerberos or windows auth for consuming web services).
Thursday, October 23, 2014
SQL Server - Recursive CTE query to get manager hierarchy
Friday, October 17, 2014
Copying AD Users into a SharePoint 2010 SPGroup
I've run into a problem with SharePoint 2010 configured for Claims auth where the claims provider wont recursively read group membership. So if you have a claims group configured with a child group that contains users, like this:
-
my_master_group
- User1
- my_child_group
- User2
And then try to assign my_master_group rights to a SharePoint site, only User1 picks up those rights. User2 is ignored. So only top level group members are ever granted rights. In my case, my source claims repository has complex nested group structure that is synced up with our orgs Active Directory. I have one master group that recursively holds all my group members and now I just want to get them into a SPGroup that I can then use for granting rights to my site. Here is my first stab at a rough solution for this, until the provider issue is resolved.
Create a scheduled task to copy AD members into a SPGroup
The plan is to first query AD, get a recursive list of my_master_group members and add them to the SharePoint group sp_my_master_group.
Get a list of AD Principal Objects
Insert Principals into a SharePoint Group
Friday, May 23, 2014
Exporting Data from SQL Server Managment Studio as INSERT statements
- Right click on the database and go to Tasks -> Generate Scripts
- Select the tables that you want to generate the script for
- Go to Set scripting options and click the Advanced button
- In the General category, go to type of data to script
- There are 3 options: Schema Only, Data Only, and Schema and Data. Select the appropriate option and click on OK
Thursday, March 13, 2014
Automated Browser Testing using Selenium
I just started using Selenium for automated browser testing. It's turning out to be really nice as a kind of SharePoint site warm up script too. This is what I've got running on my box right now for automated tests on a schedule:
Setting up a Selenium test script to run on a schedule on Windows 7- Create a directory on your local system c:\selenium
- Install the seleniumn IDE FireFox plugin for recording/saving tests.
- Record a browser test with a starting point of https://www.google.com.
- save the test as c:\selenium\MyGoogleTest.html.
- Save the test suite as c:\selenium\MyGoogleTestSuite.html.
- Download selenium-server-standalone-2.40.0.jar so you can run test scripts from the command line
- copy the selenium-server-standalone-2.40.0.jar to c:\selenium\selenium-server-standalone-2.40.0.jar
- create a bat file to run your test script command c:\selenium\RunMyGoogleTest.bat
- Edit the bat file and paste in this command:
java -jar selenium-server-standalone-2.40.0.jar -htmlSuite "*firefox" "https://www.google.com/" "c:\selenium\MyGoogleTestSuite.html" "c:\Selenium\results.html"
- Open a command prompt, change the current directory to c:\selenium and run RunMyGoogleTest.bat. Firefox should launch and show your tests being performed.
- Create a new windows scheduled task. In the action tab, add a new action.
- Action: Start a program
- Program/Script: C:\Selenium\RunMyGoogleTest.bat
- Start in (optional): c:\Selenium
- You can setup the task to run as any user that's ever logged onto your computer. So if you dont want to see windows opening every time the task runs, change the user the task runs as something other than your user account.
- Run the scheduled task by hand to confirm it works. Again, it should launch firefox and run your tests.
You can force selenium to run the test slower by hacking up the test suite html. After the open command you can add setSpeed command that will force every clickAndWait method to pause before running the next command, giving the browser time to load page content. For more info - http://www.jnhasty.com/2013/02/15/using-the-setspeed-setting-in-selenium-standalone-htmlsuite-mode/