
Signature
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
Cubicle Wars - http://www.windwardreports.com/film.htm
In the case of NETWORD SERVICE the env var USERDOMAIN is an empty string. And
there are cases where I do not have a client user (scheduled reports) so I
can't use the domain part of an authenticated user.

Signature
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
Cubicle Wars - http://www.windwardreports.com/film.htm
> If my ASP.NET app is running as NETWORK SERVICE then
> Environment.UserDomainName returns NT AUTHORITY, not the domain name. Same
> for anything returning the full username.
Mark Rae - 31 Dec 2006 10:55 GMT
> In the case of NETWORD SERVICE the env var USERDOMAIN is an empty string.
> And
> there are cases where I do not have a client user (scheduled reports) so I
> can't use the domain part of an authenticated user.
Obviously, it's easy enough to get the machine name of the IIS server, but
to return the name of the domain that it's part of I think you'd have to use
ActiveDirectory...
David Thielen - 31 Dec 2006 16:27 GMT
Any idea how? I've tried and this seems to be a very difficult problem.

Signature
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
Cubicle Wars - http://www.windwardreports.com/film.htm
> > In the case of NETWORD SERVICE the env var USERDOMAIN is an empty string.
> > And
[quoted text clipped - 4 lines]
> to return the name of the domain that it's part of I think you'd have to use
> ActiveDirectory...
Mark Rae - 31 Dec 2006 17:19 GMT
> Any idea how? I've tried and this seems to be a very difficult problem.
E, well this certainly works for me:
using (DirectorySearcher objSearcher = new DirectorySearcher())
{
strDomain = objSearcher.SearchRoot.Name.Substring(3);
}
David Thielen - 31 Dec 2006 20:51 GMT
Is (string) objSearcher.SearchRoot.Properties["name"].Value;
legit (ie will always work)? Or better to use yours below? I want to make
sure whatever I use works on 100% of the system configurations out there.

Signature
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
Cubicle Wars - http://www.windwardreports.com/film.htm
> > Any idea how? I've tried and this seems to be a very difficult problem.
>
[quoted text clipped - 4 lines]
> strDomain = objSearcher.SearchRoot.Name.Substring(3);
> }
Mark Rae - 31 Dec 2006 21:43 GMT
> Is (string) objSearcher.SearchRoot.Properties["name"].Value;
>
> legit (ie will always work)? Or better to use yours below? I want to make
> sure whatever I use works on 100% of the system configurations out there.
Sorry, but I don't know enough about it to be sure.
I suggest you post in microsoft.public.adsi.general - anything you are told
by Joe Kaplan you can take as gospel... :-)