Entity Framework Connection String

  Code Snippet using System.Data.EntityClient;               EntityConnectionStringBuilder entityConString = new EntityConnectionStringBuilder()             {                 Metadata = @"res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl",                 Provider = "System.Data.SqlClient",                 ProviderConnectionString = new System.Data.SqlClient.SqlConnectionStringBuilder                 {                     InitialCatalog = dbname,                     DataSource = servername,                     IntegratedSecurity = false,                     UserID = user,                     Password = pwd                 }                   .ConnectionString             };             return entityConString.ToString();

Get Logged In User while Impersonate or Run as Admin

Sometimes when a program is run as Administrator, using the System.Security.Principal.WindowsIdentity.GetCurrent().Name will return always System or NT Authority\System. This happens while running the exe under windows service or by Installer class in the windows application. The below code will solve this issue. Code Snippet public static string GetParentUser(int pid)         {             string parentUserAccount = null;             string... Continue Reading →

Create a website or blog at WordPress.com

Up ↑