![]() |
|
|
|||
|
SDS.AM Extensions
I like the new System.DirectoryServices.AccountManagement namespace. It
seems like it will make a lot of things easier to manage. I am having trouble understanding how to extend and use the UserPrincipal to get some things done. These include searching and updating the proxyAddresses attribute for users. I tried to do this by Extending the UserPrincipal as follows: [DirectoryObjectClass("User")] [DirectoryRdnPrefix("CN")] public class Account : UserPrincipal { // Constructor public Account(PrincipalContext ou, string samAccountName, string password) : base(ou, samAccountName, password, true) { } [DirectoryProperty("proxyAddresses")] public string[] ProxyAddresses { get { int len = ExtensionGet("proxyAddresses").Length; string[] addresses = new string[len]; object[] addressesRaw = ExtensionGet("proxyAddresses"); for (int i = 0; i < len; i++) { addresses[i] = (string)addressesRaw[i]; } return addresses; } set { ExtensionSet("proxyAddresses", value); } } I can use this to create a new account (User) in the AD but cannot use it to retrieve the proxyAddresses. The various find methods only return Principals or UserPrincipals and I cannot cast them to Account. I am using http://msdn.microsoft.com/en-us/library/bb552835.aspx as a model to work from. How can I access/update/search the proxyAddresses field for users? Thanks, bob |
![]() |
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|