//I need to get permissions of Network shared folders and display in Grid.. When retrieving local files shares it shows the accounts name correctly but when i try to retrieve shared folder permission it displays SID for account name instead of Showing username.. so i use the above code to convert SID value to username and displays in the grid. But the problem is while retrieving directly username or group name for some objects it throws error on it.. so that i want to add a if condition before the coding begins i.e., if it receives User object name in IDentityReference directly it shows to grid value else if it receives SID value in IDentityReference it comes into the loop and convert it into username..//
string sid = ace.IdentityReference.Value;
SecurityIdentifier s = new SecurityIdentifier(sid);
string username = s.Translate(typeof(NTAccount)).Value;
dtrow["Account"] = username;