簡體   English   中英

Openldap 支持控制密碼策略

[英]Openldap supportedControl Password Policy

Openldap supportedControl 列出:1.3.6.1.4.1.42.2.27.8.5.1(密碼策略)

使用 .Net DirectoryServices.Protocols,我已經用盡了所有可能的方法來檢索此控件提供的響應信息。

我在 Cygwin 環境中使用本地構建/運行的最新 Openldap 源,在構建中啟用了所有與 PPolicy 相關的配置,並且 PPolicy 已配置和工作/測試。

通過修改目錄服務編程指南中的示例,鏈接: http://dunnry.com/blog/2006/05/11/DotNetDevGuideToDirectoryServicesCompanionSiteLaunched.aspx

, 使用填充了 DirectoryControl 的 SearchRequest,該 DirectoryControl 配置為請求

密碼策略,什么都沒有。 Everything looks good in the Server Source: http://www.openldap.org/devel/gitweb.cgi?p=openldap.git;a=blob_plain;f=servers/slapd/overlays/ppolicy.c;hb=HEAD

有沒有人在 SearchRequest 中使用 .Net DirectoryControls 運氣好?

這是我一直在嘗試的一些代碼:

    _authConnect.AuthType = AuthType.Basic;
// credentials.UserName is a user DN format, w/password and null domain
_authConnect.Credential = credentials;
Debug.WriteLine("PV: " + _authConnect.SessionOptions.ProtocolVersion);

var sr = //new ExtendedRequest();
         new SearchRequest(credentials.UserName, "(objectclass=*)", SearchScope.Base, null);
         //new DsmlAuthRequest(credentials.UserName);
        var isCritical = false;
    var ppolicy = "1.3.6.1.4.1.42.2.27.8.5.1";
        // ppolicy request and response control is referred to by the same OID
        sr.Controls.Add(new DirectoryControl(ppolicy, null, isCritical, true));
    sr.Controls.Add(new DirectoryControl(ppolicy, new byte[8], isCritical, false));

try
{
  var response = (SearchResponse)_authConnect.SendRequest(sr);
  DirectoryControl[] c = response.Controls;
  if (c.Rank > 0 && c.GetLength(0) > 0)
  {
     Debug.WriteLine(c[0].Type + " value: " + c[0].GetValue());
  }
  SearchResultEntry entry = response.Entries[0];
  c = entry.Controls;
  if (c.Rank > 0 && c.GetLength(0) > 0)
  {
     Debug.WriteLine(c[0].Type + " value: " + c[0].GetValue());
  }  
  return true;
}
catch (LdapException ex)
{
  Debug.WriteLine(ex.Message);
}

我和你有同樣的問題,嘗試了很多事情都沒有成功,然后就沒有時間了。 我注意到的問題是 openldap 只在綁定請求中發送密碼過期信息。 我通過啟用服務器上的所有日志記錄發現了這一點。 所以我開始嘗試找到一種方法來使用帶有綁定請求的目錄控件。 我找不到使用 S.DS.P LdapConnection class 的方法。 然后我開始修改連接 object 並獲取 ldaphandle 變量。 有了它,我可以像 S.DS.P 一樣使用它直接調用 c-api。 我環顧了一下 openldap 的源代碼,注意到它的工具使用了 sasl 綁定機制,而沒有在該庫中使用控件的簡單綁定機制。 它在 winldap 中的工作方式不同。 如果這樣做,它將返回錯誤的參數響應代碼。 我嘗試的最后一件事是調用 ldap_bind 的異步版本並讀回消息。 不幸的是,響應中沒有任何控制。 我認為,由於我沒有發送它們,因此即使 openldap 日志文件說它正在設置警告,它們也沒有被退回。 這是我使用任何內置 winldap 綁定方法的唯一希望。

我要嘗試但沒有時間的最后一件事是使用控件構建我自己的綁定消息,並使用 ldap_extended_operation_s function 將它們發送到服務器。 http://msdn.microsoft.com/en-us/library/aa366580(v=VS.85).aspx如果我在這個項目上有一些額外的時間,我可能會 go 回來嘗試一下。 如果我這樣做,我會在這里報告。 最終,如果這是解決方案,使用 Novell 的 ldapcsharp 庫可能會更容易。 看起來可以使用它發送帶有服務器控件的綁定請求。 我只探索了 winldap api,因為我對它有點熟悉,而且我們已經非常熟悉使用 DirectoryServices.Protocols。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM