Active directory 如何在C中读取msExchMailboxSecurityDescriptor属性#

Active directory 如何在C中读取msExchMailboxSecurityDescriptor属性#,active-directory,Active Directory,我正在尝试读取广告中的所有用户属性 如何读取C#中的msExchMailboxSecurityDescriptor属性 我使用了下面的代码,但是我得到了一个cast错误。欢迎提出任何建议 DirectoryObjectSecurity oSec = new ActiveDirectorySecurity(); oSec.SetSecurityDescriptorBinaryForm((byte[])val); String m_Value = oSec.GetSecurityDes

我正在尝试读取广告中的所有用户属性

如何读取C#中的
msExchMailboxSecurityDescriptor
属性

我使用了下面的代码,但是我得到了一个cast错误。欢迎提出任何建议

  DirectoryObjectSecurity oSec = new ActiveDirectorySecurity();
  oSec.SetSecurityDescriptorBinaryForm((byte[])val);

  String m_Value = oSec.GetSecurityDescriptorSddlForm(AccessControlSections.All); 
  return m_Value; 

嗯。我能弄明白。下面为感兴趣的人提供了代码。我希望微软能拿出一些代码样本,这样人们就不必伤脑筋了

     SecurityDescriptor sd = (SecurityDescriptor) p_InputValue;
           AccessControlList acl = (AccessControlList)sd.DiscretionaryAcl;
              String m_Trustee = "";
              String m_AccessMask = "";
              String m_AceType = "";
              String m_ReturnValue="";

                  foreach (AccessControlEntry ace in (IEnumerable)acl)
                    {
                      m_Trustee = m_Trustee + "," + ace.Trustee;
                     m_AccessMask = m_AccessMask + "," + ace.AccessMask.ToString();
                      m_AceType = m_AceType + "," +ace.AceType.ToString();

                     }
         m_ReturnValue="Trustee: " + m_Trustee + " " + "AccessMask: " + m_AccessMask + "AceType: " + m_AceType;
         return m_ReturnValue

有三个问题,虽然我猜您不会回答:您使用了哪个版本的Exchange?p_InputValue从何而来?哪些名称空间是使用的类型?我发现这个链接有一个具有相同SecurityDescriptor类型的代码示例。希望能有帮助。