2011-08-29 66 views
3

我想讀在廣告中的所有用戶屬性。如何閱讀在C#msExchMailboxSecurityDescriptor屬性

如何閱讀在C#msExchMailboxSecurityDescriptor屬性?

我用下面的代碼,但我有一個投錯誤。歡迎大家提出意見。

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

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

回答

2

好的。我能弄明白。下面的代碼給有興趣的人。我希望微軟公佈了一些代碼樣本,這樣人們就不必折首了。

 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_Return value="Trustee: " + m_Trustee + " " + "AccessMask: " + m_AccessMask  + "AceType: " + m_AceType 

回報m_ReturnValue

+0

三個問題,但我想你不會回答他們:你使用哪個版本的Exchange? p_InputValue來自哪裏?哪些名稱空間是使用的類型? – Alexander

+1

我發現此鏈接https://msdn.microsoft.com/en-us/library/ms180874(v=vs.80).aspx,它具有與SecurityDescriptor類型相同的代碼示例。希望能幫助到你。 –