-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The Mono's library Novell.Directory.Ldap has been made to be on par with
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
Showing
18 changed files
with
853 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/BackupRestoreConstants.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} | ||
} |
192 changes: 192 additions & 0 deletions
192
mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/LdapBackupRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
* 2.16.840.1.113719.1.27.100.96</p><br> | ||
* | ||
* <p>The requestValue has the following format:<br> | ||
* | ||
* requestValue ::=<br> | ||
* objectDN LDAPDN<br> | ||
* mts(modification timestamp) INTEGER<br> | ||
* revision INTEGER<br> | ||
* passwd 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); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.