0

クラスと派生クラスを作成しました。別のクラスから派生クラスを呼び出すにはどうすればよいですか? 以下のクラス、派生クラス (拡張クラス)、および派生クラスを呼び出している場所を参照してください。

UserPrincipalクラス:

private UserPrincipal GetUserFromAD1(string userLoginName)
{
        String currentUser = userLoginName;
        String domainName = userLoginName.Split('\\')[0];
        UserPrincipal user = null;

        SPSecurity.RunWithElevatedPrivileges(delegate()
        {
            using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, domainName))
            {

                user = UserPrincipal.FindByIdentity(pc, System.DirectoryServices.AccountManagement.IdentityType.SamAccountName, currentUser);

            }
        });
        return user;
    }    

拡張UserPrincipalクラス:

    [DirectoryObjectClass("user")]
    [DirectoryRdnPrefix("CN")]

    public class UserPrincipalExtended : UserPrincipal
    {
        public UserPrincipalExtended(PrincipalContext context): base(context)                

        {

        }
        [DirectoryProperty("department")]
        public string department
        {
            get
            {
                if (ExtensionGet("department").Length != 1)
                    return null;
                return (string)ExtensionGet("department")[0];
            }
            set { this.ExtensionSet("department", value); }
        }

方法

private void GetUserInfoFromAD1()
{
        try
        {

            XPathNavigator rootNode = this.MainDataSource.CreateNavigator();
            this.initialData = rootNode.SelectSingleNode("/my:myFields/my:Wrapper", this.NamespaceManager).OuterXml;
            using (SPSite site = new SPSite(SPContext.Current.Web.Url))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    UserPrincipalExtended userFromAD = this.GetUserFromAD1(web.CurrentUser.LoginName);

コード行で

this.GetUserFromAD1(web.CurrentUser.LoginName) 

エラーが発生します:

型を暗黙的に変換できません.......

4

1 に答える 1