Click here to Skip to main content
12,630,025 members (27,446 online)
   

C#

 
GeneralRe: Getting clock time from NIST Pin
Satips31-May-07 19:38
memberSatips31-May-07 19:38 
GeneralRe: Getting clock time from NIST Pin
M. J. Jaya Chitra31-May-07 20:30
memberM. J. Jaya Chitra31-May-07 20:30 
QuestionExperiment -- Looking for suggestions Pin
simplicitylabs31-May-07 18:26
membersimplicitylabs31-May-07 18:26 
AnswerRe: Experiment -- Looking for suggestions Pin
Martin#31-May-07 21:05
memberMartin#31-May-07 21:05 
QuestionHow to terminate a login session if disconnected from internet Pin
fukchai200031-May-07 17:29
memberfukchai200031-May-07 17:29 
AnswerRe: How to terminate a login session if disconnected from internet Pin
Dave Kreskowiak31-May-07 18:26
mvpDave Kreskowiak31-May-07 18:26 
GeneralRe: How to terminate a login session if disconnected from internet Pin
fukchai200031-May-07 22:42
memberfukchai200031-May-07 22:42 
GeneralRe: How to terminate a login session if disconnected from internet Pin
Dave Kreskowiak1-Jun-07 5:25
mvpDave Kreskowiak1-Jun-07 5:25 
QuestionXML over serial port Pin
sklepikov31-May-07 14:40
membersklepikov31-May-07 14:40 
AnswerRe: XML over serial port Pin
Christian Graus31-May-07 14:57
staffChristian Graus31-May-07 14:57 
GeneralRe: XML over serial port Pin
sklepikov1-Jun-07 4:44
membersklepikov1-Jun-07 4:44 
QuestionGive Access to Certificate in Store Pin
mikker_12331-May-07 14:02
membermikker_12331-May-07 14:02 
AnswerRe: Give Access to Certificate in Store Pin
blackjack21501-Jun-07 0:55
memberblackjack21501-Jun-07 0:55 
GeneralRe: Give Access to Certificate in Store Pin
mikker_1231-Jun-07 1:23
membermikker_1231-Jun-07 1:23 
Dunno... Add method works great for me. Anyways I found some kind of solution googling, it works, but I don't like it. Anyways, if someone has better solution please post, until then I'll use this:

private static void PlaceInStore(X509Certificate2 cert)
{
    X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
 
    try
    {
        store.Open(OpenFlags.ReadWrite);
 
        if (!store.Certificates.Contains(cert))
            store.Add(cert);
 
        int indexInStore = store.Certificates.IndexOf(cert);
        cert = store.Certificates[indexInStore];
 
        AddAccessToCertificate(cert, "ARCHITECT\\testuser");
    }
    finally
    {
        store.Close();
    }
}
 
private static void AddAccessToCertificate(X509Certificate2 cert, string user)
{
    RSACryptoServiceProvider rsa = cert.PrivateKey as RSACryptoServiceProvider;
 
    if (rsa != null)
    {
        string keyfilepath =
            FindKeyLocation(rsa.CspKeyContainerInfo.UniqueKeyContainerName);
 
        FileInfo file = new FileInfo(keyfilepath + "\\" +
            rsa.CspKeyContainerInfo.UniqueKeyContainerName);
 
        FileSecurity fs = file.GetAccessControl();
 
        NTAccount account = new NTAccount(user);
        fs.AddAccessRule(new FileSystemAccessRule(account,
        FileSystemRights.FullControl, AccessControlType.Allow));
 
        file.SetAccessControl(fs);
    }
}
 
private static string FindKeyLocation(string keyFileName)
{
    string text1 =
    Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
    string text2 = text1 + @"\Microsoft\Crypto\RSA\MachineKeys";
    string[] textArray1 = Directory.GetFiles(text2, keyFileName);
    if (textArray1.Length > 0)
    {
        return text2;
    }
    string text3 =
    Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
    string text4 = text3 + @"\Microsoft\Crypto\RSA\";
    textArray1 = Directory.GetDirectories(text4);
    if (textArray1.Length > 0)
    {
        foreach (string text5 in textArray1)
        {
            textArray1 = Directory.GetFiles(text5, keyFileName);
            if (textArray1.Length != 0)
            {
                return text5;
            }
        }
    }
    return "Private key exists but is not accessible";
}

GeneralRe: Give Access to Certificate in Store Pin
DotNet_Naeem2-Sep-09 14:49
memberDotNet_Naeem2-Sep-09 14:49 
Questionhow to access protected-pass folder Pin
alex.almeida31-May-07 13:26
memberalex.almeida31-May-07 13:26 
AnswerRe: how to access protected-pass folder Pin
mikker_12331-May-07 14:12
membermikker_12331-May-07 14:12 
GeneralRe: how to access protected-pass folder Pin
alex.almeida1-Jun-07 3:28
memberalex.almeida1-Jun-07 3:28 
AnswerRe: how to access protected-pass folder Pin
Dave Kreskowiak31-May-07 14:29
mvpDave Kreskowiak31-May-07 14:29 
GeneralRe: how to access protected-pass folder Pin
Christian Graus31-May-07 14:30
staffChristian Graus31-May-07 14:30 
GeneralRe: how to access protected-pass folder Pin
Dave Kreskowiak31-May-07 14:43
mvpDave Kreskowiak31-May-07 14:43 
GeneralRe: how to access protected-pass folder Pin
mikker_12331-May-07 14:48
membermikker_12331-May-07 14:48 
GeneralRe: how to access protected-pass folder Pin
Dave Kreskowiak31-May-07 18:25
mvpDave Kreskowiak31-May-07 18:25 
GeneralRe: how to access protected-pass folder Pin
alex.almeida1-Jun-07 4:48
memberalex.almeida1-Jun-07 4:48 
GeneralRe: how to access protected-pass folder Pin
mikker_1231-Jun-07 8:59
membermikker_1231-Jun-07 8:59 
GeneralRe: how to access protected-pass folder Pin
alex.almeida4-Jun-07 5:01
memberalex.almeida4-Jun-07 5:01 
QuestionHow to monitor an incoming TCP/IP connection in C#? Pin
adeeeljan31-May-07 12:14
memberadeeeljan31-May-07 12:14 
AnswerRe: How to monitor an incoming TCP/IP connection in C#? Pin
Dave Kreskowiak31-May-07 14:21
mvpDave Kreskowiak31-May-07 14:21 
QuestionForm Opacity and OnClose() Pin
Wraith Lunati31-May-07 12:01
memberWraith Lunati31-May-07 12:01 
AnswerRe: Form Opacity and OnClose() Pin
Christian Graus31-May-07 12:10
staffChristian Graus31-May-07 12:10 
GeneralRe: Form Opacity and OnClose() Pin
Wraith Lunati31-May-07 12:31
memberWraith Lunati31-May-07 12:31 
GeneralRe: Form Opacity and OnClose() Pin
Christian Graus31-May-07 12:50
staffChristian Graus31-May-07 12:50 
GeneralRe: DummyClose Pin
Wraith Lunati31-May-07 13:22
memberWraith Lunati31-May-07 13:22 
GeneralRe: Form Opacity and OnClose() Pin
Wraith Lunati31-May-07 12:58
memberWraith Lunati31-May-07 12:58 
GeneralRe: Form Opacity and OnClose() Pin
Christian Graus31-May-07 13:43
staffChristian Graus31-May-07 13:43 
GeneralRe: Article? Pin
Wraith Lunati31-May-07 14:11
memberWraith Lunati31-May-07 14:11 
GeneralRe: Article? Pin
Christian Graus31-May-07 14:32
staffChristian Graus31-May-07 14:32 
GeneralRe: Article? Pin
Wraith Lunati31-May-07 15:05
memberWraith Lunati31-May-07 15:05 
Questionkill proccess with C# Pin
crash89331-May-07 11:06
membercrash89331-May-07 11:06 
AnswerRe: kill proccess with C# Pin
Tarakeshwar Reddy31-May-07 11:41
memberTarakeshwar Reddy31-May-07 11:41 
GeneralRe: kill proccess with C# Pin
crash89331-May-07 12:19
membercrash89331-May-07 12:19 
GeneralRe: kill proccess with C# Pin
Christian Graus31-May-07 12:26
staffChristian Graus31-May-07 12:26 
GeneralRe: kill proccess with C# Pin
Tarakeshwar Reddy31-May-07 13:37
memberTarakeshwar Reddy31-May-07 13:37 
GeneralRe: kill proccess with C# Pin
crash89331-May-07 20:24
membercrash89331-May-07 20:24 
GeneralRe: kill proccess with C# Pin
crash89331-May-07 21:01
membercrash89331-May-07 21:01 
AnswerRe: kill proccess with C# Pin
Martin#31-May-07 21:20
memberMartin#31-May-07 21:20 
GeneralRe: kill proccess with C# Pin
crash89331-May-07 21:46
membercrash89331-May-07 21:46 
GeneralRe: kill proccess with C# Pin
Martin#31-May-07 22:02
memberMartin#31-May-07 22:02 
GeneralRe: kill proccess with C# Pin
crash8933-Jun-07 15:58
membercrash8933-Jun-07 15:58 
AnswerRe: kill proccess with C# Pin
Martin#10-Jun-07 21:07
memberMartin#10-Jun-07 21:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.161205.3 | Last Updated 7 Dec 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid