例外
org.json.JSONException:3990 [字符3991第1行]处的未终止字符串
JavaScript代码
[HttpPost]
public ActionResult Index(CreateUser model)
{
//Domain name
var domainName = "XXX";
//Fully distinguished name of OU to create user in
var location = model.Location;
var userOU = "OU=" + location + ",OU=XXX,DC=XXX,DC=com";
using (var pc = new PrincipalContext(ContextType.Domain, domainName, userOU))
{
using (var up = new UserPrincipal(pc))
{
//Creates username and display name from firstname and lastname
**var userName = model.FirstName[0].ToString().ToLower() + model.LastName.ToString().ToLower();**
var displayName = model.FirstName + " " + model.LastName;
var password = "XXX";
up.Name = displayName;
up.DisplayName = displayName;
up.GivenName = model.FirstName;
up.MiddleName = model.MiddleI;
up.Surname = model.LastName;
up.SamAccountName = userName;
up.EmailAddress = userName + "@XXX.com";
up.UserPrincipalName = userName + "@XXX.com";
up.SetPassword(password);
up.Enabled = true;
up.ExpirePasswordNow();
try
{
//Attempt to save the account to AD
up.Save();
}
catch (Exception e)
{
ModelState.AddModelError("", "Exception creating user object. " + e);
return View(model);
}
//Set department to add
DirectoryEntry entry = up.GetUnderlyingObject() as DirectoryEntry;
//DirectoryEntry group = entry.Children.Add("CN="+ )
entry.Properties["department"].Value = model.Department;
//entry.Properties["member"].Add(up);
try
{
//try and commit the changes
entry.CommitChanges();
}
catch(Exception e)
{
ModelState.AddModelError("", "Exception adding department. " + e);
return View(model);
}
}
}
//Redirect to completed page if successful
return RedirectToAction("Completed");
}//POST Index
代码在下面的行中失败。
function dialogUpdateConfirm(action) {
$('#dialogConfirm').dialog({
title : Update',
bgiframe : true,
width : 500,
height : 200,
autoOpen : false,
modal : true,
show : 'fold',
hide : 'blind',
resizable : false,
buttons : {
Yes : function() {
$(this).dialog("close");
var json = new Object();
json.arr = jsonSaveObject;
console.log(JSON.stringify(json));
// This output to the console is not getting cut off. But the jsonWFSManual is getting cut off once the java code executes.
window.location.href = 'updatemanual?action=' + action + '&jsonWFSManual=' + JSON.stringify(json);
},
No : function() { $(this).dialog("close"); }
}
});
这里有字符限制问题吗?