English 中文(简体)
Linq tokou in ASP. Net MVC 在使用假人时担任网络服务
原标题:Linq to SQL in ASP.Net MVC Runs as Network Service when using Impersonation

我有一个伙伴关系。 MVC控制员网采取行动,即立即发送数据内容标语,我目前正在将直接连接到建筑商。 我正在使用假人,我已经核实控制器行动的目前用户是目前的Windows Auth。 然而,在运行一个LQ时,网络用户 追查总是作为网络服务。 另一项目在网络应用中参考了数据背景标的,但我正在将直接连接到构件中,因此不应成为问题。 这里是控制者目前采取的行动:

        // verified the user is the current Windows Auth. user of the web app
        var user = this.User;

        var connectionString = "Data Source=serverName;Initial Catalog=dbName;Integrated Security=true";
        var context = new CustomDataContext(connectionString);
        var test = context.Customers.Select(i => i.fullname).ToList();

除查询总是作为网络服务而不是目前的用户外,所有查询都得到罚款。 任何想法,说明为什么情况如此以及如何解决?

问题回答

因此,你所看到的是代表团的问题。 身份证明单流自动流出二流。

如果你把所有东西组合起来,用于视窗认证,那么,你需要打上你的数据库,开放电话,暂时使用视窗身份,供在你的网络应用之外使用。 守则如下:

using (((WindowsIdentity)HttpContext.Current.User.Identity).Impersonate())
{
    // Perform database or network access here
}

你也许想在检查中总结一下目前的身份,并确保它有一个视窗身份。

你们最有可能看到网络服务,因为这是一个缺省账户,即应用程序库在综合系统6和7中运行。

总的来说,在蚊帐应用中,有两种选择:

  1. The < identity /> tag in web.config
  2. Change the identity of the application pool in IIS

这两种选择都是全球性的,将影响每一项要求。

然而,它像你想要把窗户 au为用户的每个用户。 如果是,见。 样本代码的本管理知识基础条款——具体来说,题为中指定特定用户的章节。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

Running numbers in SQL

I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签