问题
I'm updating code that interacts with the AD in our application. The current code uses the ActiveDs interface. I'm changing the code to use the System.DirectoryServices.AccountManagement namespace. Our application allows a user to store a password hint. This is stored in the AD under a user defined parameter. I know I can do this with the DirectoryEntry.Invoke("put")
method.
Is there anyway to do this with UserPrincipal, or do I need to call the GetUnderlyingObject
method and then the DirectoryEntry.Invoke("put")
call?
Any suggestions/comments would be appreciated.
回答1:
The UserPrincipal
class is extensible, so you can "surface" more of the properties of the underlying DirectoryEntry
object right on your user principal.
Using that extensibility technique, which is explained in the MSDN article Managing Directory Security Principals in the .NET Framework 3.5, you should be able to also make available a custom attribute (which I assume is how you store that password hint in your DirectoryEntry
) on an extended UserPrincipal
class.
来源:https://stackoverflow.com/questions/10726858/a-userprincipal-equivalent-to-directoryentry-invoke