Click here to Skip to main content
15,867,999 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I tried this code -->

* But it does not work!! Can you help me please?

label1.Text = System.Environment.UserDomainName.ToString()+"\\Users";
DirectoryInfo Din = new DirectoryInfo(@"F:\");
DirectorySecurity Ds = Din.GetAccessControl();
Ds.AddAccessRule(new FileSystemAccessRule(label1.Text, FileSystemRights.FullControl, AccessControlType.Allow));
Din.SetAccessControl(Ds);
MessageBox.Show("Done");


The exception was here in this code:
Ds.AddAccessRule(new FileSystemAccessRule(label1.Text, FileSystemRights.FullControl, AccessControlType.Allow));


How can I solve this problem "Some or all identity references could not be translated."?
Posted
Updated 26-Mar-11 3:32am
v2
Comments
Henry Minute 26-Mar-11 1:35am    
"But it does not work" will not help people to understand your problem.

You should explain in what way it does not work. Does it give an exception? If so include the message in your question. Does it run OK but fail to apply the required permission?

Please edit your question to include this information.
Sandeep Mewara 26-Mar-11 2:46am    
Reply from OP:
Is it because the operating system???
My operating system is Win7 32-bit
[no name] 26-Mar-11 3:35am    
What error it shows. Have you tried it using exceptions?
Renon_Pal 26-Mar-11 9:28am    
The exception was here in this code:

Ds.AddAccessRule(new FileSystemAccessRule(label1.Text, FileSystemRights.FullControl, AccessControlType.Allow));

Some or all identity references could not be translated.

1 solution

When you get an exception that you have never seen before, and you are not sure what it means, the best thing to do is to paste the error message into the search box of your favourite search engine.

I have just done this with your error Some or all identity references could not be translated and all of the first couple of pages were concerned with systems running SharePoint. Does this apply in your case? If so I would suggest that you do a search yourself and work your way through any likely looking hits.

If it is not a SharePoint system then this[^] thread seems to suggest that an invalid user might be the cause, although, of course, this may not apply in your case.
I found this thread by searching for directorysecurity "Some or all identity references could not be translated". If you need more then I would suggest that you do the same and, again, work through the hits until you find something that fits your situation.
 
Share this answer
 
Comments
Renon_Pal 26-Mar-11 12:14pm    
Thank you so much sir, but there is another problem :(

The exception: Attempted to perform an unauthorized operation.

In this code line: Din.SetAccessControl(Ds);

Can you help me!!
Henry Minute 26-Mar-11 12:38pm    
And did you follow my previous advice and search for it?

If you did, then you should say so right from the start, so that people know how to try to help.

If you haven't searched yet then do so and come back again if you have no luck.

The most likely thing that can cause this is a permissions problem, either for the application or the user of the application, if that might give you a clue.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900