次はローカルマシン(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;
}
私のローカルシステムに別のサーバーとiisのアプリケーションがあるので、ローカルシステムにアプリケーションを公開してiisに追加しました。私はWindows認証を有効にしています。 – sukumar2267
"ApplicationPoolIdentity"アカウントで実行されています – sukumar2267