1

我正在使用集成安全性来访问 BD 和 Windows 身份验证,当它在开发环境中并附带我的计算机帐户(Windows 凭据)时,所有查询、插入和更新都正常工作,使用我的 Windows 凭据连接到我的数据库.

现在我正在发布我的 Web 服务器,所以我必须对我的服务中的查询方法进行一些调整,例如:

[OperationBehavior(Impersonation = ImpersonationOption.Required)]
public IQueryable<mtto_EmpleadoAdmin> GetMtto_EmpleadoAdmin()
{
    using (((WindowsIdentity)HttpContext.Current.User.Identity).Impersonate())
    {
        return this.ObjectContext.mtto_EmpleadoAdmin;
    }
}

在我的网络服务器中它可以正常工作,咨询并为我带来所有信息

但我不明白,为什么我的InsertUpdate方法甚至做出类似于我在查询方法中所做的更改,仍然不起作用

 [OperationBehavior(Impersonation = ImpersonationOption.Required)]
 public void InsertMtto_EmpleadoAdmin(mtto_EmpleadoAdmin mtto_EmpleadoAdmin)
 {
     using (((WindowsIdentity)HttpContext.Current.User.Identity).Impersonate())
     {
         if ((mtto_EmpleadoAdmin.EntityState != EntityState.Detached))
         {
             this.ObjectContext.ObjectStateManager.ChangeObjectState(mtto_EmpleadoAdmin, EntityState.Added);
         }
         else
         {
             this.ObjectContext.mtto_EmpleadoAdmin.AddObject(mtto_EmpleadoAdmin);
         }
     }

 }

我连接到 BD 时出错,因为它尝试使用 Web 凭据而不是 Windows 凭据,例如必须有人帮助我吗?

4

0 回答 0