locked
Some or all identity references could not be translated.??

    Question

  •  

    for the code below im getting the error as "Some or all identity references could not be translated"

    i want to to give folder access or folder deny permissions to users on my system, when im trying to give permissions for the users on the domain, the below code is working fine

    but when im trying to give permissions for the usres on my system im getting the error, where i need to change the code?

                DirectoryInfo myDirectoryInfo = new DirectoryInfo(textBox1.Text);

                DirectorySecurity myDirectorySecurity = myDirectoryInfo.GetAccessControl();
                string User = System.Environment.UserDomainName + "\\" +
                                                               comboBox1.SelectedItem.ToString();
                myDirectorySecurity.AddAccessRule(new FileSystemAccessRule(User,
                                                   FileSystemRights.Read, AccessControlType.Deny));



                myDirectoryInfo.SetAccessControl(myDirectorySecurity);
                MessageBox.Show("Permissions Altered Successfully");

                         
    Monday, July 02, 2012 4:47 AM

Answers

All replies

  • it maybe like some of the folder/directory the user you are logged in with doesn't have rights to grant permissions.


    Mark Answered, if it solves your question and Vote if you found it helpful.
    Rohit Arora

    Monday, July 02, 2012 5:38 AM
  • Hi we need ,
    Does "users on my system" means users in your computer but not in the domain ?
    If so , you should use "COMPUTERNAME\MyAccount" where computername is the name of your local machine and MyAccount is the name of a valid windows account with the proper access security to change file permissions. So ,please modify

    string User = System.Environment.UserDomainName + "\\" + comboBox1.SelectedItem.ToString();

    to

    string User = System.Environment.MachineName + "\\" + combobox1.SelectedItem.ToString();

    In addition ,please make sure the account exist and that they are spelled correctly .
    Here is a related thread , maybe helpful to you :http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/14a7c2f6-f50a-441a-ad08-addc7650ba7f/

    Regards ,



    Wednesday, July 04, 2012 8:12 AM
    Moderator