08-20-04 07:51 AM
Dear Stefan,
The information you provide is certainly valuable, but it does NOT answer my
question.
You are answering the questions "How can I find out the identity of a user
running my current ASP.NET application from WITHIN the ASP.NET application
itself?"
This is NOT my question.
My question is "How can I programmatically retrieve identity of an
application pool running an ASP.NET application from EXTERNAL application -
namely an installer app?"
This is very different question and I think is much harder too.
Once again, I am running a separate program (for the sake of simplicity lets
say an exe windows application) and from that EXTERNAL program I need to
somehow find out certain configuration parameters of IIS. The parameter that
I want to find out is the windows user account running one of the webs on th
e
IIS.
I hope that makes it clear. Just in case, I am including 2 of my original
posts in here, which I am asking you to read again please as they do describ
e
the situation in all the details.
Thank you very much.
POST#1:
I am creating a setup application for my ASP.NET web site. I need to make
several directories in that web writable for the account running ASP.NET
application during the installation process - change ACLs on those
directories.
The problem for me is to find out which windows account will be running the
web application I am installing. I need to get this information
programmatically from within the installer.
I would also prefer a method that will work for IIS 5 as well, although
there, I have been told, we could parse machine.config file to extract the
identity information. But if there is some universal WMI call (or some other
technology) that will just give me the identity of an IIS web site or virtua
l
directory that would be great.
If not, please give me some other direction. I really don’t want to give
“Everyone” “Full Control” on those folders.
Thank you.
POST#2:
I probably didn't make myself clear.
I would like to know the identity of the ASP.NET user not when running web
application itself already, but before I install it. From within the
installer I have to know which windows user account to give write access to
certain folders within the web that is being installed – please see the
original post. When it's already installed I don't think I can do much there
anymore.
Let me try to explain it in a different way:
1. I am setting up a web application.
2. I am selecting a web or virtual directory to install my app to during
installation.
3. The web application contains the following folders structure:
/html
/html/controls
/html/logs
4. I want to be able to create files inside the /html/logs directory when
the web application runs programmatically
5. To be able to create files in the /html/logs folder a windows user
Account running the web application has to have “write” permission to th
e
/html/logs folder.
6. Because each server is configured differently I can not hardcode any
value (like “ASPNET” or “NETWORK ACCOUNT”) into my setup program. So
I have
to determine it dynamically when the setup program runs.
7. Hence the question: How to determine the identity of the account running
certain web site or virtual directory?
So, do you have any suggestions?
""Stefan Schachner[MSFT]"" wrote:
>
> --------------------
> <pj71rDkhEHA.2632@cpmsftngxa10.phx.gbl>
> web
> to
> there
> the
> So I have
> running
> For ASP.NET - C#:
>
> Here is a sample that will allow you to get the account information...
>
> // Create a text box called "txtInfo" on an ASP.NET form
> // Add "using System.Web.Security;" at the top of the form.
> // Add the code below to a new button
> // run the form and click the button.
> string sInfo = "";
> sInfo = "Authentication Information" + "\n";
> sInfo += "User:" + "\n";
> sInfo += " IdentityIsAuthenticated: " +
> User.Identity.IsAuthenticated.ToString() +
> "\n";
> sInfo += " IdentityName: " + User.Identity.Name + "\n";
> sInfo += " IdentityAuthenticationType: " + User.Identity.AuthenticationTyp
e
> +
> "\n";
> sInfo += " IsInAdminRole: " + User.IsInRole("Administrators").ToString() +
> "\n";
> sInfo += "Current User:" + "\n";
> sInfo += " WindowsIdentity: " +
> System.Security.Principal.WindowsIdentity.GetCurrent().Name + "\n";
> sInfo += " AuthenticationType: " +
> System.Security.Principal.WindowsIdentity.GetCurrent().AuthenticationType
+
> "\n";
> txtInfo.Text = sInfo;
>
> IHTH,
>
> Stefan Schachner
> Microsoft Community Tech Lead
> This posting is provided “AS IS” with no warranties, and
> confers no rights.
>
>
[ Post a follow-up to this message ]
|