简体   繁体   中英

DirectorySearcher can't find fax property

I am useing DirectorySearcher to find details about the current user.

UserPrincipal u = UserPrincipal.Current;
DirectoryEntry? user = u.GetUnderlyingObject() as DirectoryEntry;
DirectorySearcher ds = new DirectorySearcher(user);
ds.PropertiesToLoad.AddRange(new[]
{
    "fax", "displayName", "streetAddress", "department", "telephoneNumber"
});
var entry = ds.FindOne();

"fax" is not in the Property collection

I confirmd that the value is set in the AD.

Powershell displays it correctly

PS C:\Users\Henrik Halbritter> get-aduser "Henrik Halbritter" -Property "fax" | select -Property fax

fax
---
0123456

Instead of fax , try FacsimileTelephoneNumber . AD property names can be very inconsistent in the way they are referenced.

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