Click here to Skip to main content
13,297,048 members (64,417 online)
   

C#

 
AnswerRe: To bind a value from DataGridView to textbox Pin
Seishin#5-Jun-07 22:57
memberSeishin#5-Jun-07 22:57 
Question"Loading of the ImageList did not succeed" error Pin
Mertli Ozgur Nevres4-Jun-07 22:44
memberMertli Ozgur Nevres4-Jun-07 22:44 
AnswerRe: "Loading of the ImageList did not succeed" error Pin
Luc Pattyn5-Jun-07 1:45
memberLuc Pattyn5-Jun-07 1:45 
GeneralRe: "Loading of the ImageList did not succeed" error Pin
Mertli Ozgur Nevres5-Jun-07 2:13
memberMertli Ozgur Nevres5-Jun-07 2:13 
AnswerRe: "Loading of the ImageList did not succeed" error Pin
Hesham yassin6-Jun-07 9:20
memberHesham yassin6-Jun-07 9:20 
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 
QuestionManagementBaseObject.SetPropertyValue not working Pin
Le Centriste31-May-07 9:45
memberLe Centriste31-May-07 9:45 
AnswerRe: ManagementBaseObject.SetPropertyValue not working Pin
Dave Kreskowiak31-May-07 9:50
mvpDave Kreskowiak31-May-07 9:50 
GeneralRe: ManagementBaseObject.SetPropertyValue not working Pin
Le Centriste31-May-07 9:53
memberLe Centriste31-May-07 9:53 

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 |
Web02 | 2.8.171207.1 | Last Updated 15 Dec 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid