简体   繁体   中英

TerminalServer Profil Path and C# .NET3.5

I am programming a software which can allow me to add users and modify them in ACTIVE DIRECTORY on Windows Server 2008 R2

I used

using System.DirectoryServices.AccountManagement;

[DirectoryRdnPrefix("CN")]
[DirectoryObjectClass("Person")]
public class UserPrincipalEx : UserPrincipal
{
    // Implement the constructor using the base class constructor. 
public UserPrincipalEx(PrincipalContext context)
    : base(context)
{ }

// Implement the constructor with initialization parameters.    
public UserPrincipalEx(PrincipalContext context,
                     string samAccountName,
                     string password,
                     bool enabled)
    : base(context, samAccountName, password, enabled)
{ }

// Create the "TermSrvProfilePath" property.    
[DirectoryProperty("msTSProfilePath")]
public string TermSrvProfilePath
{
    get
    {
        if (ExtensionGet("msTSProfilePath").Length != 1)

            return "vide";

        return (string)ExtensionGet("msTSProfilePath")[0];
    }
    set { ExtensionSet("msTSProfilePath", value); }
}


public static new UserPrincipalEx FindByIdentity(PrincipalContext context,
                                              string identityValue)
{
    return (UserPrincipalEx)FindByIdentityWithType(context,
                                                 typeof(UserPrincipalEx),
                                                 identityValue);
}

[DirectoryProperty("wWWHomePage")]
public string wWWHomePage
{
    get
    {
        if (ExtensionGet("wWWHomePage").Length != 1)
            return null;

        return (string)ExtensionGet("wWWHomePage")[0];

    }
    set { this.ExtensionSet("wWWHomePage", value); }
}

}

So, and what is the result ?

I successfully read the wWWHomePage attribute but it is empty when i try to get : TermSrvProfilePath ....

I don't understand, i am fully lost !

The msTS... properties are not used. The information you are looking for is stored in the userProperties BLOB.

See this article for more information:

http://webactivedirectory.com/active-directory/active-directory-attributes-for-remote-desktop-services/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM