2017-06-14 17 views
1

次はローカルマシン(2015年)で正常に動作しますが、iis7で解放されたユーザープリンシパルはnullになります。いずれにしても私はこれを手伝うことができます。UserPrincipal.currentはiis7でnullを返します。

[ActionName("Login")] 
    [HttpGet] 
    [CacheFilter(TimeDuration = 100)] 
    public async Task<List<Hashtable>> Login([FromUri]string id, string netPwd) 
    { 
     await Task.Delay(100); 
     bool response = false; 

     // Build user id and password strings from KGP network credentials 
     string uid = id; 
     string password = netPwd; 
     Hashtable hashChild = new Hashtable(); 

     List<Hashtable> list = new List<Hashtable>(); 

     // Define LDAP connection 
     DirectoryEntry root = new DirectoryEntry("LdapAccount", uid, password, AuthenticationTypes.Secure); 
     try 
     { 
      object connected = root.NativeObject; 
      UserPrincipal userPrincipal = UserPrincipal.Current; 

      if (HttpContext.Current.User.Identity.IsAuthenticated) 
      { 
       string s = "tri"; 
      } 
      string EmployeeId = userPrincipal.EmployeeId; 

      domainName = System.Environment.UserDomainName; 

}

答えて

0

SYSTEMアカウントを使用して実行しているIISですか?最終的に私は、このための答えを得た

+0

私のローカルシステムに別のサーバーとiisのアプリケーションがあるので、ローカルシステムにアプリケーションを公開してiisに追加しました。私はWindows認証を有効にしています。 – sukumar2267

+0

"ApplicationPoolIdentity"アカウントで実行されています – sukumar2267

0

.. はここ

using (HostingEnvironment.Impersonate()) 
     { 

//コード

}

を追加する必要があります - 認証は、アプリケーションに基づいて匿名認証、通常の認証であります。

関連する問題