我在 ASP.NET MVC 内的 Models 文件夹下创建了两个类:-
namespace TMS.Models
{
public class ADIntigration
{
public static DomainContext GetUserDetails()
{
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain))
{
IPrincipal principal = HttpContext.Current.User;
WindowsIdentity identity = ((WindowsIdentity)principal.Identity);
UserPrincipal user = UserPrincipal.FindByIdentity(pc, identity.Name);
if (principal != null)
{
return new DomainContext() {
userGuid = user.Guid,
DisplayName = user.DisplayName,
GivenName = user.GivenName,
EmailAddress = user.EmailAddress
};
}
}
return null;
}
}
}
&
namespace TMS.Models
{
class DomainContext
{
public class domainContext
{
public Nullable<Guid> userGuid { get; set; }
public string DisplayName { get; set; }
public string GivenName { get; set; }
public string EmailAddress { get; set; }
}
}
}
但我收到一个构建错误:-
可访问性不一致:返回类型“project.Models.DomainContext”比方法“project.Models.ADIntigration.GetUserDetails()”更难访问
那么我该如何解决这个问题呢?