Friday, September 12, 2008

Impersonating in Windows (WinForm)

Impersonating in asp.net is as simple as just adding a tag in web.config but in windows I found few links which were using kernel dll to impersonate. Article I found on theserverside.net shows new features in .net 2.0 which makes it very easy to do this.

Quote:

System.Diagnostics.ProcessStartInfo pInfo =   new System.Diagnostics.ProcessStartInfo();
            SecureString ss = new SecureString();
                          ... append password characters
            pInfo.Password = ss;
            pInfo.UserName = @"domain\alice";
            pInfo.FileName = @"c:\windows\notepad.exe";
            pInfo.UseShellExecute = false;
            Process.Start(pInfo);

Link: http://www.theserverside.net/tt/articles/showarticle.tss?id=NewSecurityFeatures

No comments: