【问题标题】:How to get object of "ntSecurityDescriptor" of a active directory user如何获取活动目录用户的“ntSecurityDescriptor”对象
【发布时间】:2012-11-04 15:11:03
【问题描述】:

我正在开发一个网站。我必须找到用户的值不能更改用户的密码属性。我得到这个链接 http://msdn.microsoft.com/en-us/library/aa746448(v=vs.85).aspx[^] 根据我必须找到该用户的“ntSecurityDescriptor”值。他们正在使用 DirectoryEntry 类来查找,但在我的情况下,我使用的是 LdapConnection 类。 如果我使用入口类,我将无法与服务器建立连接,因此我将其更改为 LdapConnection 类。现在我不知道如何找到价值。

【问题讨论】:

    标签: c# asp.net openldap


    【解决方案1】:

    我找到了我的解决方案。

     SearchResponse response = (SearchResponse)connection.SendRequest(request);
                DirectoryAttribute attribute = response.Entries[0].Attributes["ntSecurityDescriptor"];
    
                if (attribute != null)
                {
                    const string PASSWORD_GUID = "{ab721a53-1e2f-11d0-9819-00aa0040529b}";
                    const int ADS_ACETYPE_ACCESS_DENIED_OBJECT = 6;
                    bool fEveryone = false;
                    bool fSelf = false;
    
                    ActiveDs.ADsSecurityUtility secUtility = new ActiveDs.ADsSecurityUtility();
                    ActiveDs.IADsSecurityDescriptor sd = (IADsSecurityDescriptor)secUtility.ConvertSecurityDescriptor((byte[])attribute[0], (int)ADS_SD_FORMAT_ENUM.ADS_SD_FORMAT_RAW, (int)ADS_SD_FORMAT_ENUM.ADS_SD_FORMAT_IID);
                    ActiveDs.IADsAccessControlList acl = (ActiveDs.IADsAccessControlList)sd.DiscretionaryAcl;
    
                    foreach (ActiveDs.IADsAccessControlEntry ace in acl)
                    {
                        if ((ace.ObjectType != null) && (ace.ObjectType.ToUpper() == PASSWORD_GUID.ToUpper()))
                        {
                            if ((ace.Trustee == "Everyone") && (ace.AceType == ADS_ACETYPE_ACCESS_DENIED_OBJECT))
                            {
                                fEveryone = true;
                            }
                            if ((ace.Trustee == @"NT AUTHORITY\SELF") && (ace.AceType == ADS_ACETYPE_ACCESS_DENIED_OBJECT))
                            {
                                fSelf = true;
                            }
    
                            break;
                        }
                    }
    
                    if (fEveryone || fSelf)
                    {
                        return Global.RequestContants.CANT_CHANGE_PASSWORD;
                    }
                    else
                    {
                        return string.Empty;
                    }
                }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-12
      • 2011-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多