I have a C # application that scans the directory and collects some information. I would like to display the account name for each file. I can get the SID for the File Info object on the local system, and then doing this:
string GetNameFromSID (Security Identifier sid) {NTAccount ntAccount = (NTAccount) sid.Translate (typeof (NTACCount)); Return ntAccount.ToString (); } However, it does not work for files on the network, presumably because the translation () function works only with local user accounts. I thought I had an LDAP lookup Can I do the following, so I tried the following: string GetNameFromSID (Security Identifier CID) {string str = "LDAP: //
It seems that this will work, in which the access to "directory name" for a few seconds is hanging, as if it is shutting down and inquires from the network, but Then it throws a system. Runtime Interp Services COMException
Do anyone know how I can get an arbitrary file or SID account name? I do not know more about networking or LDAP or something. It has a directory called directory search, maybe I should use it, but it wants a domain name, and I do not know how to get it - I have the path to the directory with all scanning.
Thanks in advance.
The translation method of the security reference object works on non-local sid but only for the domain account For local accounts in other machines or non-domain setup, you will need PInvoke to look for the LookupAccountSid function to specify specific machine names that require lookup.
Comments
Post a Comment