我正在处理应该管理自定义团队结构的应用程序,因此当团队负责人添加其成员时,我希望他们只添加登录添加从AD中提取名字和姓氏。当我在本地运行它时它工作正常,但我在服务器上得到500内部服务器错误。
jQuery的:
var json = { "ldapLogin": ldapLogin };
var saveAction = $.ajax({
type: "POST",
url: manageLdapURL,
contentType: "application/json; charset=utf-8",
data: JSON.stringify(json),
dataType: "json",
success: function (json) {
if (json.Status == 1) {
firstName = json.FirstName;
lastName = json.LastName;
if (!json.isMember) {
$(".dialog-confirm-warning").dialog('open');
}
}
else if (json.Status == 2) {
$("p .warning").text(json.Message);
$(".dialog-user-do-not-exist").dialog('open');
}
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr.status);
console.log(thrownError);
console.log(xhr.responseText);
}
});
控制器:
[HttpPost]
[Authorize]
public JsonResult ManageAgentLdap(string ldapLogin)
{
bool isServiceDeskMember = false;
try
{
UserPrincipal foundUser = Utility.getUserNameFromLdap(ldapLogin);
if (foundUser != null)
{
ServiceDeskWorgroupsDataContext db2 = new ServiceDeskWorgroupsDataContext();
bool serviceDeskMembersExist = db2.v_MandaysPortalUserClarifications.Any(l => l.LDAPLogin == ldapLogin);
if (serviceDeskMembersExist)
{
isServiceDeskMember = true;
}
return Json(new
{
Status = 1,
FirstName = foundUser.GivenName,
LastName = foundUser.Surname,
isMember = isServiceDeskMember
});
}
}
catch (DataException e)
{
ModelState.AddModelError("", "Unable to query Active Directory. Try again, and if the problem persists see your system administrator.");
}
return Json(new { Status = 2, FirstName = "", LastName = "", isMember = isServiceDeskMember });
}
我可以发布方法getUserNameFromLdap(ldapLogin),但我很确定这不是问题,因为它在其他地方使用并且工作正常。
我的想法是我违反了一些我不知道的内部服务器证券(我还没有完全熟悉.NET MVC)。
编辑:
我终于能够得到错误详情,就是这样:
[DirectoryServicesCOMException (0x80072020): An operations error occurred.
]
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +387793
System.DirectoryServices.DirectoryEntry.Bind() +36
System.DirectoryServices.DirectoryEntry.get_AdsObject() +31
System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne) +78
System.DirectoryServices.DirectorySearcher.FindAll() +9
System.DirectoryServices.ActiveDirectory.Forest.GetDomains() +410
[ActiveDirectoryOperationException: An operations error occurred.
]
System.DirectoryServices.ActiveDirectory.Forest.GetDomains() +738
System.DirectoryServices.ActiveDirectory.Forest.get_Domains() +38...
答案 0 :(得分:0)
确保' System.Web.Extensions.dll'在你的bin文件夹中。