Home All Groups Group Topic Archive Search About

Translate BUILTIN to domain name

Author
9 Feb 2006 1:33 PM
Anders K. Olsen
Hello group

I'm trying to list the users and groups who has read access to a file.

I use .NET 2.0 and FileInfo.GetAccessControl().GetAccessRules(...) and then
loop through the FileSystemAccessRule objects. Using these objects, I can
get the NTAccount object using the IdentityReference property.

I have a problem with the "well known" accounts, because they return the
same name for each computer that I ask. E.g. the Users account is called
BUILTIN\Users on my computer. I need to translate this BUILTIN domain name
to an actual computer or domain name. Just like it is done when I click on
the Security tab of the file property dialog.

If it is on my local computer, I guess that I sould just translate it into
the local computer name. However, what should I do if it is on a remote
computer? If the remote computer is a Domain controller, it looks as if I
should translate it to <DOMAIN>\Users instead of <COMPUTERNAME>\Users.

Is there a nice way to do this translation? It should be possible, because
Windows does it when you look at the Security tab on a file property dialog.
Is it possible to do using .NET?

Thank you for your help

Regards
Anders

Author
13 Feb 2006 7:06 AM
Narendra
There is an environement variable called userdomain and LogonServer.
If you log on to local computer, they will have value computer name.
If you log on to remote computer (domain controller), they will have remote
computer name. You can access environment variable using system.Environment
class.

Show quoteHide quote
"Anders K. Olsen" wrote:

> Hello group
>
> I'm trying to list the users and groups who has read access to a file.
>
> I use .NET 2.0 and FileInfo.GetAccessControl().GetAccessRules(...) and then
> loop through the FileSystemAccessRule objects. Using these objects, I can
> get the NTAccount object using the IdentityReference property.
>
> I have a problem with the "well known" accounts, because they return the
> same name for each computer that I ask. E.g. the Users account is called
> BUILTIN\Users on my computer. I need to translate this BUILTIN domain name
> to an actual computer or domain name. Just like it is done when I click on
> the Security tab of the file property dialog.
>
> If it is on my local computer, I guess that I sould just translate it into
> the local computer name. However, what should I do if it is on a remote
> computer? If the remote computer is a Domain controller, it looks as if I
> should translate it to <DOMAIN>\Users instead of <COMPUTERNAME>\Users.
>
> Is there a nice way to do this translation? It should be possible, because
> Windows does it when you look at the Security tab on a file property dialog.
> Is it possible to do using .NET?
>
> Thank you for your help
>
> Regards
> Anders
>
>
>
>
>
Author
13 Feb 2006 12:44 PM
Anders K. Olsen
"Narendra" <Naren***@discussions.microsoft.com> wrote in message
news:B1D45FAF-CC64-44A2-8317-D56B71844CA4@microsoft.com...
> There is an environement variable called userdomain and LogonServer.
> If you log on to local computer, they will have value computer name.
> If you log on to remote computer (domain controller), they will have
> remote
> computer name. You can access environment variable using
> system.Environment
> class.

Thank you, I will take a look at those variables. They may be able to help
me with some of my problems. However they will probably not be able to help
me, when I access a remote file on another server. In this case I will be
logged in on the local computer, but the file will belong to the remote
server and therefore the BUILTIN domain will refere to the remote server.

Regards
Anders