Skip to content

Commit

Permalink
The Mono's library Novell.Directory.Ldap has been made to be on par with
Browse files Browse the repository at this point in the history
the Novell's CSHARP LDAP SDK (version 2.1.8). All the changes have been
commited together. Refer Changelog for the full log of changes.
-Palaniappan.


svn path=/trunk/mcs/; revision=85999
  • Loading branch information
Palaniappan N committed Sep 19, 2007
1 parent 2bac2fc commit b0c3b16
Show file tree
Hide file tree
Showing 18 changed files with 853 additions and 18 deletions.
57 changes: 57 additions & 0 deletions mcs/class/Novell.Directory.Ldap/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,60 @@
2007-19-09 Palaniappan N <npalaniappan@novell.com>

The folder is made in sync. with the Novell Forge's C# LDAP SDK with the following updates:

*Novell.Directory.Ldap :
- Connection.cs: Checked the condition, whether the sockets
created by BOTH SSL and cleartext connections are open / null
in Connection.cs
- Connection.cs: Added a new catch block in Connection.cs to
catch the socket exceptions.
- Connection.cs: Version has been updated to 2.1.8
- LdapResponse.cs: Changes made to monitor the events which
caused problems with eDirectory 8.8 SP1 release, because of the
LdapResponse structure.
- LdapException.cs: A fix for the bug which deals about the
exceptions caused while using events with lots of create/modify events
- LdapAttributeSchema.cs: Superior was not set properly. Corrected.
- Message.cs: To fix the issue of seeing duplicate records while searching

*Novell.Directory.Ldap.Extensions :
- Added support for Backup-Restore of LDAP by including the following classes
# LdapBackupRequest.cs
# LdapBackupResponse.cs
# LdapRestoreRequest.cs
# BackupRestoreConstants.cs

*Novell.Directory.Ldap.Utilclass :
- DN.cs: Done a fix in by correcting the misplaced decrement operator
which caused malfunctioning of isDescendantOf() method

*Novell.Directory.Ldap.Events :
- LdapEventSource.cs: Exception has been thrown in case of supply of
negative sleep interval

*Novell.Directory.Ldap.Events.Edir.EventData :
- ValueEventData.cs: A new property BinaryData has been implemented in the
class to enable applications retrieve the binary data as such from the
ASN1OctetString with out converting it in to a String

*Novell.Directory.Ldap.Rfc2251 :
- RfcIntermediateResponse.cs: The variable m_responseNameIndex has been
modified to get value 0 also to fix an issue related to parsing the response.
- RfcModifyDNRequest.cs: SetIdentifier method has been applied to newSuperior
to make rename work properly with all LDAP servers.

* Changelog:
- Updated

* Novell.Directory.Ldap.dll.sources:
- Added the new file entries of the Backup-Restore Extension

* Novell.Directory.Ldap.vmwcsproj:
- Added the new file entries of the Backup-Restore Extension

* Novell.Directory.Ldap20.csproj:
- Added the new file entries of the Backup-Restore Extension

2005-12-06 Konstantin Triger <kostat@mainsoft.com>

* Novell.Directory.Ldap.vmwcsproj: fixing conditional compilation constants.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ public string Data
}
}

protected byte[] binData;
public byte[] BinaryData
{
get
{
return binData;
}
}
protected string strEntry;
public string Entry
{
Expand Down Expand Up @@ -118,6 +126,7 @@ public ValueEventData(EdirEventDataType eventDataType, Asn1Object message)
: base(eventDataType, message)
{
int[] length = new int[1];
Asn1OctetString octData;

strPerpetratorDN =
((Asn1OctetString) decoder.decode(decodedData, length)).stringValue();
Expand All @@ -134,7 +143,9 @@ public ValueEventData(EdirEventDataType eventDataType, Asn1Object message)
timeStampObj =
new DSETimeStamp((Asn1Sequence) decoder.decode(decodedData, length));

strData = ((Asn1OctetString) decoder.decode(decodedData, length)).stringValue();
octData = ((Asn1OctetString) decoder.decode(decodedData, length));
strData = octData.stringValue();
binData = SupportClass.ToByteArray(octData.byteValue());

nVerb = ((Asn1Integer) decoder.decode(decodedData, length)).intValue();

Expand All @@ -152,6 +163,7 @@ public override string ToString()
buf.AppendFormat("(Attribute={0})", strAttribute);
buf.AppendFormat("(Classid={0})", strClassId);
buf.AppendFormat("(Data={0})", strData);
buf.AppendFormat("(Data={0})", binData);
buf.AppendFormat("(Entry={0})", strEntry);
buf.AppendFormat("(Perpetrator={0})", strPerpetratorDN);
buf.AppendFormat("(Syntax={0})", strSyntax);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ public int SleepInterval
}
set
{
sleep_interval = value;
if(value <= 0)
throw new ArgumentOutOfRangeException("SleepInterval","cannot take the negative or zero values ");
else
sleep_interval = value;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/******************************************************************************
* The MIT License
* Copyright (c) 2006 Novell Inc. www.novell.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the Software), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*******************************************************************************/
//
// Novell.Directory.Ldap.Extensions.BackupRestoreConstants.cs
//
// Author:
// Palaniappan N (NPalaniappan@novell.com)
//
// (C) 2006 Novell, Inc (http://www.novell.com)
//

using System;

namespace Novell.Directory.Ldap.Extensions
{
public class BackupRestoreConstants
{

/**
* A constant for eDirectory LDAP Based Backup Request OID.
*/
public const String NLDAP_LDAP_BACKUP_REQUEST = "2.16.840.1.113719.1.27.100.96";

/**
* A constant for eDirectory LDAP Based Backup Response OID.
*/
public const String NLDAP_LDAP_BACKUP_RESPONSE = "2.16.840.1.113719.1.27.100.97";

/**
* A constant for eDirectory LDAP Based Restore Request OID.
*/
public const String NLDAP_LDAP_RESTORE_REQUEST = "2.16.840.1.113719.1.27.100.98";


/**
* A constant for eDirectory LDAP Based Restore Response OID.
*/
public const String NLDAP_LDAP_RESTORE_RESPONSE = "2.16.840.1.113719.1.27.100.99";

/**
* Default constructor
*/
public BackupRestoreConstants():base()
{
return;
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
/******************************************************************************
* The MIT License
* Copyright (c) 2006 Novell Inc. www.novell.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the Software), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*******************************************************************************/
//
// Novell.Directory.Ldap.Extensions.BackupRestoreConstants.cs
//
// Author:
// Palaniappan N (NPalaniappan@novell.com)
//
// (C) 2006 Novell, Inc (http://www.novell.com)
//


using System;
using System.IO;

using Novell.Directory.Ldap;
using Novell.Directory.Ldap.Asn1;

/**
*
* This class provides an LDAP interface for object based backup
* of eDirectory objects. The backup API not only get the objects
* but all the DS level attributes associated with the objects.
*
* <p>The information available includes such items as modification timestamp,
* revision,data blob consisting of backup data of any eDirectory Object. The API
* support backing of both non-encrypted and encrypted objects
* </p>
*
* <p>To get information about any eDirectory Object, you must
* create an instance of this class and then call the
* extendedOperation method with this object as the required
* LdapExtendedOperation parameter.</p>
*
* <p>The getLdapBackupRequest extension uses the following OID:<br>
* &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.96</p><br>
*
* <p>The requestValue has the following format:<br>
*
* requestValue ::=<br>
* &nbsp;&nbsp;&nbsp;&nbsp; objectDN&nbsp;&nbsp;&nbsp; LDAPDN<br>
* &nbsp;&nbsp;&nbsp;&nbsp; mts(modification timestamp) INTEGER<br>
* &nbsp;&nbsp;&nbsp;&nbsp; revision&nbsp;&nbsp;&nbsp; INTEGER<br>
* &nbsp;&nbsp;&nbsp;&nbsp; passwd&nbsp;&nbsp;&nbsp; OCTET STRING</p>
*/

namespace Novell.Directory.Ldap.Extensions
{
public class LdapBackupRequest: LdapExtendedOperation
{

static LdapBackupRequest()
{
/*
* Register the extendedresponse class which is returned by the server
* in response to a LdapBackupRequest
*/
try
{
LdapExtendedResponse.register(
BackupRestoreConstants.NLDAP_LDAP_BACKUP_RESPONSE,
Type.GetType("Novell.Directory.Ldap.Extensions.LdapBackupResponse"));
}
catch (TypeLoadException e)
{
Console.Error.WriteLine("Could not register Extended Response - Class not found");
}
catch (Exception e)
{
Console.Error.WriteLine(e.StackTrace);
}
}

/**
*
* Constructs an extended operations object for getting data about any Object.
*
* @param objectDN The DN of the object to be backed up
* <br>
* @param passwd The encrypted password required for the object to
* be backed up
* <br>
* @param stateInfo The state information of the object to backup.
* This parameter is a String which contains combination of modification
* timestamp and revision number of object being backed up. The format
* of both modification time stamp and revision should pertain to eDirectoty
* standard format of taking modification timestamp and revision.
* Separator being used between these two is a '+' character.<br>
*
*
* @exception LdapException A general exception which includes an error
* message and an LDAP error code.
*/
public LdapBackupRequest(String objectDN, byte[] passwd, String stateInfo):
base(BackupRestoreConstants.NLDAP_LDAP_BACKUP_REQUEST, null)
{

int mts; // Modifaction time stamp of the Object
int revision; // Revision number of the Object
String mtsStr, revisionStr;

try
{
if (objectDN == null)
throw new ArgumentException("PARAM_ERROR");

//If encrypted password has null reference make it null String
if(passwd == null)
passwd = System.Text.Encoding.UTF8.GetBytes("");


if (stateInfo == null)
{
// If null reference is passed in stateInfo initialize both
// mts and revision
mts = 0;
revision = 0;
}
else
{
// Parse the passed stateInfo to obtain mts and revision
stateInfo = stateInfo.Trim();
int index = stateInfo.IndexOf('+');
if(index == -1)
throw new ArgumentException("PARAM_ERROR");
mtsStr = stateInfo.Substring(0, index);
revisionStr = stateInfo.Substring(index + 1);
try
{
mts = int.Parse(mtsStr);
}
catch (FormatException e)
{
throw new LdapLocalException("Invalid Modification Timestamp send in the request", LdapException.ENCODING_ERROR);
}
try
{
revision = int.Parse(revisionStr);
}
catch (FormatException e)
{
throw new LdapLocalException(
"Invalid Revision send in the request",
LdapException.ENCODING_ERROR);
}
}

MemoryStream encodedData = new MemoryStream();
LBEREncoder encoder = new LBEREncoder();

// Encode data of objectDN, mts and revision
Asn1OctetString asn1_objectDN = new Asn1OctetString(objectDN);
Asn1Integer asn1_mts = new Asn1Integer(mts);
Asn1Integer asn1_revision = new Asn1Integer(revision);
Asn1OctetString asn1_passwd = new Asn1OctetString(SupportClass.ToSByteArray(passwd));

asn1_objectDN.encode(encoder, encodedData);
asn1_mts.encode(encoder, encodedData);
asn1_revision.encode(encoder, encodedData);
asn1_passwd.encode(encoder, encodedData);

// set the value of operation specific data
setValue(SupportClass.ToSByteArray(encodedData.ToArray()));

}
catch (IOException ioe)
{
throw new LdapException("ENCODING_ERROR", LdapException.ENCODING_ERROR, (String) null);
}
}
}
}
Loading

0 comments on commit b0c3b16

Please sign in to comment.