A UserPrincipal equivalent to DirectoryEntry.Invoke?

你说的曾经没有我的故事 提交于 2019-12-10 18:53:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!