Is this possible? Code sample would be nice.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
Actually, the question was how to get two of the properties for a .NET 3.5
(System.DirectoryServices.AccountManagement.)UserPrincipal
-object not given auserPrincipalName
.Here how to do that with an extension method:
The above code will work in most cases (that is it will work for standard Text/String Single-Value Active Directory attributes). You'll need to modify the code and add more error handling code for your environment.
You use it by add the "Extension Class" to your project and then you can do this:
(BTW; this would have been a great use for Extension Properties - too bad it won't be in C# 4 either.)
Something like this should do it if the department and company properties exist for the user.