Openldap supportedControl listed: 1.3.6.1.4.1.42.2.27.8.5.1 (Password policy)
Using .Net DirectoryServices.Protocols, I've exhausted all possible methods of retrieving the response information provided by this control.
I'm using the latest Openldap Source built/running locally in a Cygwin environment with all PPolicy related config enabled in the build and the PPolicy configured and working/tested.
By modifying an example from the directory services programming guide, link: http://dunnry.com/blog/2006/05/11/DotNetDevGuideToDirectoryServicesCompanionSiteLaunched.aspx
, to use a SearchRequest populated with a DirectoryControl configured to request the
Password Policy, gets me nothing. 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
Has anyone had any luck using .Net DirectoryControls in a SearchRequest?
Here is some code I've been trying:
_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);
}