我有用于对域进行身份验证的操作方法和视图。然后将COM对象传递给下面的视图。如果用户单击我想要做某事的按钮(如下面的动作方法中所示),我需要COM对象。问题是模型Connector传递为null。
查看:
@model Decsec.Models.Connector
@using (Html.BeginForm("ClassifyPrivUsers", "AuthenticateAD", FormMethod.Post))
{
<input type="submit" value="Evaluate" class="btn btn btn-block" name="ClassifyPrivUsers" formmethod="post" />
}
行动方法:
[HttpPost]
public ActionResult ClassifyPrivUsers(Connector connector)
{
// Extract privileged users from the Active Directory
var privilegedUsers = ADExtractor.PrivilegedAccess(connector.pc);
System.Diagnostics.Debug.WriteLine("PRIVILEGED USERS EXTRACTED");
// Load the trained model for privileged users
Classifier adminAccCl = LoadModel("LMT");
System.Diagnostics.Debug.WriteLine("MODEL LOADED");
.....
型号:
public class Connector
{
public int id { get; set; }
public PrincipalContext pc { get; set; }
public DirectoryEntry de { get; set; }
public Connector(int id, PrincipalContext pc, DirectoryEntry de)
{
this.id = id;
this.pc = pc;
this.de = de;
}
public Connector() { }
}