开发者

How to read msExchMailboxSecurityDescriptor attribute in C#

I am trying to read all the user attributes in AD.

H开发者_C百科ow to read msExchMailboxSecurityDescriptor attribute in C# ?

I used the following code but I got a cast error. Any suggestions would be welcome.

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

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


Ok. I was able to figure it out. The code is given below for anyone interested. I wish Microsoft had put out some code samples so that people do not have to break their heads.

     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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜