Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,99 @@
/******************************************************************************
* The MIT License
* Copyright (c) 2003 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.AbortPartitionOperationRequest.cs
//
// Author:
// Sunil Kumar (Sunilk@novell.com)
//
// (C) 2003 Novell, Inc (http://www.novell.com)
//
using System;
using Novell.Directory.Ldap;
using Novell.Directory.Ldap.Asn1;
using Novell.Directory.Ldap.Utilclass;
namespace Novell.Directory.Ldap.Extensions
{
/// <summary>
/// Aborts the last partition operation that was requested on the
/// specified partition if the operation is still pending.
///
/// The AbortPartitionRequest extension uses the following OID:
/// 2.16.840.1.113719.1.27.100.29
///
/// The requestValue has the following format:
///
/// requestValue ::=
/// flags INTEGER
/// partitionDN LdapDN
/// </summary>
public class AbortPartitionOperationRequest:LdapExtendedOperation
{
/// <summary> Constructs an extended operation object for aborting a partition operation.
///
/// </summary>
/// <param name="partitionDN">The distinguished name of the replica's
/// partition root.
///
/// </param>
/// <param name="flags">Determines whether all servers in the replica ring must
/// be up before proceeding. When set to zero, the status of the
/// servers is not checked. When set to Ldap_ENSURE_SERVERS_UP,
/// all servers must be up for the operation to proceed.
///
/// </param>
/// <exception> LdapException A general exception which includes an error message
/// and an Ldap error code.
/// </exception>
public AbortPartitionOperationRequest(System.String partitionDN, int flags):base(ReplicationConstants.ABORT_NAMING_CONTEXT_OP_REQ, null)
{
try
{
if ((System.Object) partitionDN == null)
throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
LBEREncoder encoder = new LBEREncoder();
Asn1Integer asn1_flags = new Asn1Integer(flags);
Asn1OctetString asn1_partitionDN = new Asn1OctetString(partitionDN);
asn1_flags.encode(encoder, encodedData);
asn1_partitionDN.encode(encoder, encodedData);
setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
}
catch (System.IO.IOException ioe)
{
throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
}
}
}
}

View File

@@ -0,0 +1,128 @@
/******************************************************************************
* The MIT License
* Copyright (c) 2003 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.AddReplicaRequest.cs
//
// Author:
// Sunil Kumar (Sunilk@novell.com)
//
// (C) 2003 Novell, Inc (http://www.novell.com)
//
using System;
using Novell.Directory.Ldap;
using Novell.Directory.Ldap.Asn1;
using Novell.Directory.Ldap.Utilclass;
namespace Novell.Directory.Ldap.Extensions
{
/// <summary>
/// Adds a replica to the specified directory server.
///
/// To add a replica to a particular server, you must create an instance of
/// this class and then call the extendedOperation method with this
/// object as the required LdapExtendedOperation parameter.
///
/// The addReplicaRequest extension uses the following OID:
/// 2.16.840.1.113719.1.27.100.7
///
/// The requestValue has the following format:
///
/// requestValue ::=
/// flags INTEGER
/// replicaType INTEGER
/// serverName LdapDN
/// dn LdapDN
/// </summary>
public class AddReplicaRequest:LdapExtendedOperation
{
/// <summary>
/// Constructs a new extended operation object for adding a replica to the
/// specified server.
///
/// </summary>
/// <param name="dn">The distinguished name of the replica's partition root.
///
/// </param>
/// <param name="serverDN">The server on which the new replica will be added.
///
/// </param>
/// <param name="replicaType">The type of replica to add. The replica
/// types are defined in the ReplicationConstants class.
///
/// </param>
/// <param name="flags">Specifies whether all servers in the replica ring must be up
/// before proceeding. When set to zero, the status of the servers is not
/// checked. When set to Ldap_ENSURE_SERVERS_UP, all servers must be up for the
/// operation to proceed.
///
/// </param>
/// <exception> LdapException A general exception which includes an error message
/// and an Ldap error code.
///
/// </exception>
/// <seealso cref="ReplicationConstants.Ldap_RT_MASTER">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RT_SECONDARY">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RT_READONLY">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RT_SUBREF">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RT_SPARSE_WRITE">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RT_SPARSE_READ">
/// </seealso>
public AddReplicaRequest(System.String dn, System.String serverDN, int replicaType, int flags):base(ReplicationConstants.ADD_REPLICA_REQ, null)
{
try
{
if (((System.Object) dn == null) || ((System.Object) serverDN == null))
throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
LBEREncoder encoder = new LBEREncoder();
Asn1Integer asn1_flags = new Asn1Integer(flags);
Asn1Integer asn1_replicaType = new Asn1Integer(replicaType);
Asn1OctetString asn1_serverDN = new Asn1OctetString(serverDN);
Asn1OctetString asn1_dn = new Asn1OctetString(dn);
asn1_flags.encode(encoder, encodedData);
asn1_replicaType.encode(encoder, encodedData);
asn1_serverDN.encode(encoder, encodedData);
asn1_dn.encode(encoder, encodedData);
setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
}
catch (System.IO.IOException ioe)
{
throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
}
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -0,0 +1,130 @@
/******************************************************************************
* The MIT License
* Copyright (c) 2003 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.ChangeReplicaTypeRequest.cs
//
// Author:
// Sunil Kumar (Sunilk@novell.com)
//
// (C) 2003 Novell, Inc (http://www.novell.com)
//
using System;
using Novell.Directory.Ldap;
using Novell.Directory.Ldap.Asn1;
using Novell.Directory.Ldap.Utilclass;
namespace Novell.Directory.Ldap.Extensions
{
/// <summary>
/// Changes the type of the replica that resides
/// on the specified directory server.
///
/// To change a replica's type, you must create an instance of this class and
/// then call the extendedOperation method with this object as the required
/// LdapExtendedOperation parameter.
///
/// The changeReplicaTypeRequest extension uses the following OID:
/// 2.16.840.1.113719.1.27.100.15
///
/// The requestValue has the following format:
///
/// requestValue ::=
/// flags INTEGER
/// replicaType INTEGER
/// serverName LdapDN
/// dn LdapDN
/// </summary>
public class ChangeReplicaTypeRequest:LdapExtendedOperation
{
/// <summary>
/// Constructs a new extended operation object for changing a replica's type.
///
/// </summary>
/// <param name="dn"> The distinguished name of the replica's
/// partition root.
///
/// </param>
/// <param name="serverDN"> The server on which the replica resides.
///
///
/// </param>
/// <param name="replicaType"> The new replica type. The replica types are defined
/// in the ReplicationConstants class.
///
/// </param>
/// <param name="flags"> Specifies whether all servers in the replica ring must be up
/// before proceeding. When set to zero, the status of the servers is
/// not checked. When set to Ldap_ENSURE_SERVERS_UP, all servers must be
/// up for the operation to proceed.
///
/// </param>
/// <exception> LdapException A general exception which includes an error message
/// and an Ldap error code.
///
/// </exception>
/// <seealso cref="ReplicationConstants.Ldap_RT_MASTER">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RT_SECONDARY">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RT_READONLY">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RT_SUBREF">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RT_SPARSE_WRITE">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RT_SPARSE_READ">
/// </seealso>
public ChangeReplicaTypeRequest(System.String dn, System.String serverDN, int replicaType, int flags):base(ReplicationConstants.CHANGE_REPLICA_TYPE_REQ, null)
{
try
{
if (((System.Object) dn == null) || ((System.Object) serverDN == null))
throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
LBEREncoder encoder = new LBEREncoder();
Asn1Integer asn1_flags = new Asn1Integer(flags);
Asn1Integer asn1_replicaType = new Asn1Integer(replicaType);
Asn1OctetString asn1_serverDN = new Asn1OctetString(serverDN);
Asn1OctetString asn1_dn = new Asn1OctetString(dn);
asn1_flags.encode(encoder, encodedData);
asn1_replicaType.encode(encoder, encodedData);
asn1_serverDN.encode(encoder, encodedData);
asn1_dn.encode(encoder, encodedData);
setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
}
catch (System.IO.IOException ioe)
{
throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
}
}
}
}

View File

@@ -0,0 +1,87 @@
/******************************************************************************
* The MIT License
* Copyright (c) 2003 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.GetBindDNRequest.cs
//
// Author:
// Sunil Kumar (Sunilk@novell.com)
//
// (C) 2003 Novell, Inc (http://www.novell.com)
//
using System;
using Novell.Directory.Ldap;
using Novell.Directory.Ldap.Asn1;
using Novell.Directory.Ldap.Utilclass;
namespace Novell.Directory.Ldap.Extensions
{
/// <summary> Returns the distingusihed name of the object your are logged in as.
///
/// To use this class, you must create an instance of the
/// class and then call the extendedOperation method with this
/// object as the required LdapExtendedOperation parameter.
///
/// The returned LdapExtendedResponse object can then be converted to
/// a GetBindDNResponse object with the ExtendedREsponseFactory
/// class. This object contains methods for retrieving the distinguished
/// name.
///
/// The GetBindDNRequest extension uses the following OID:
/// 2.16.840.1.113719.1.27.100.31
///
/// The request value has a value of null.
///
/// </summary>
public class GetBindDNRequest:LdapExtendedOperation
{
static GetBindDNRequest()
{
/*
* Register the extendedresponse class which is returned by the
* server in response to a ListReplicasRequest
*/
try
{
LdapExtendedResponse.register(ReplicationConstants.GET_IDENTITY_NAME_RES, System.Type.GetType("Novell.Directory.Ldap.Extensions.GetBindDNResponse"));
}
catch (System.Exception e)
{
System.Console.Error.WriteLine("Could not register Extended Response -" + " Class not found");
}
}
/// <summary> Constructs an extended operation object for retrieving the bind dn.
///
/// </summary>
/// <exception> LdapException A general exception which includes an error
/// message and an Ldap error code.
/// </exception>
public GetBindDNRequest():base(ReplicationConstants.GET_IDENTITY_NAME_REQ, null)
{
}
}
}

View File

@@ -0,0 +1,110 @@
/******************************************************************************
* The MIT License
* Copyright (c) 2003 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.GetBindDNResponse.cs
//
// Author:
// Sunil Kumar (Sunilk@novell.com)
//
// (C) 2003 Novell, Inc (http://www.novell.com)
//
using System;
using Novell.Directory.Ldap;
using Novell.Directory.Ldap.Asn1;
using Novell.Directory.Ldap.Utilclass;
using Novell.Directory.Ldap.Rfc2251;
namespace Novell.Directory.Ldap.Extensions
{
/// <summary> Retrieves the identity from an GetBindDNResponse object.
///
/// An object in this class is generated from an LdapExtendedResponse object
/// using the ExtendedResponseFactory class.
///
/// The GetBindDNResponse extension uses the following OID:
/// 2.16.840.1.113719.1.27.100.32
///
/// </summary>
public class GetBindDNResponse:LdapExtendedResponse
{
/// <summary> Returns the identity of the object.
///
/// </summary>
/// <returns> A string value specifying the bind dn returned by the server.
/// </returns>
virtual public System.String Identity
{
get
{
return identity;
}
}
// Identity returned by the server
private System.String identity;
/// <summary> Constructs an object from the responseValue which contains the bind dn.
///
/// The constructor parses the responseValue which has the following
/// format:
/// responseValue ::=
/// identity OCTET STRING
///
/// </summary>
/// <exception> IOException The return value could not be decoded.
/// </exception>
public GetBindDNResponse(RfcLdapMessage rfcMessage):base(rfcMessage)
{
if (ResultCode == LdapException.SUCCESS)
{
// parse the contents of the reply
sbyte[] returnedValue = this.Value;
if (returnedValue == null)
throw new System.IO.IOException("No returned value");
// Create a decoder object
LBERDecoder decoder = new LBERDecoder();
if (decoder == null)
throw new System.IO.IOException("Decoding error");
// The only parameter returned should be an octet string
Asn1OctetString asn1_identity = (Asn1OctetString) decoder.decode(returnedValue);
if (asn1_identity == null)
throw new System.IO.IOException("Decoding error");
// Convert to normal string object
identity = asn1_identity.stringValue();
if ((System.Object) identity == null)
throw new System.IO.IOException("Decoding error");
}
else
{
identity = "";
}
}
}
}

View File

@@ -0,0 +1,126 @@
/******************************************************************************
* The MIT License
* Copyright (c) 2003 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.GetEffectivePrivilegesRequest.cs
//
// Author:
// Sunil Kumar (Sunilk@novell.com)
//
// (C) 2003 Novell, Inc (http://www.novell.com)
//
using System;
using Novell.Directory.Ldap;
using Novell.Directory.Ldap.Asn1;
using Novell.Directory.Ldap.Utilclass;
namespace Novell.Directory.Ldap.Extensions
{
/// <summary>
/// Returns the effective rights of one object to an attribute of another object.
///
/// To use this class, you must instantiate an object of this class and then
/// call the extendedOperation method with this object as the required
/// LdapExtendedOperation parameter.
///
/// The returned LdapExtendedResponse object can then be converted to
/// a GetEffectivePrivilegesResponse object with the ExtendedResponseFactory class.
/// The GetEffectivePrivilegesResponse class contains methods for
/// retrieving the effective rights.
///
/// The getEffectivePrivilegesRequest extension uses the following OID:
/// 2.16.840.1.113719.1.27.100.33
///
/// The requestValue has the following format:
///
/// requestValue ::=
/// dn LdapDN
/// trusteeDN LdapDN
/// attrName LdapDN
/// </summary>
public class GetEffectivePrivilegesRequest:LdapExtendedOperation
{
static GetEffectivePrivilegesRequest()
{
/*
* Register the extendedresponse class which is returned by the
* server in response to a ListReplicasRequest
*/
try
{
LdapExtendedResponse.register(ReplicationConstants.GET_EFFECTIVE_PRIVILEGES_RES, System.Type.GetType("Novell.Directory.Ldap.Extensions.GetEffectivePrivilegesResponse"));
}
catch (System.Exception e)
{
System.Console.Error.WriteLine("Could not register Extended Response -" + " Class not found");
}
}
/// <summary> Constructs an extended operation object for checking effective rights.
///
/// </summary>
/// <param name="dn"> The distinguished name of the entry whose attribute is
/// being checked.
///
/// </param>
/// <param name="trusteeDN">The distinguished name of the entry whose trustee rights
/// are being returned
///
/// </param>
/// <param name="attrName"> The Ldap attribute name.
///
/// </param>
/// <exception> LdapException A general exception which includes an error
/// message and an Ldap error code.
/// </exception>
public GetEffectivePrivilegesRequest(System.String dn, System.String trusteeDN, System.String attrName):base(ReplicationConstants.GET_EFFECTIVE_PRIVILEGES_REQ, null)
{
try
{
if (((System.Object) dn == null))
throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
LBEREncoder encoder = new LBEREncoder();
Asn1OctetString asn1_dn = new Asn1OctetString(dn);
Asn1OctetString asn1_trusteeDN = new Asn1OctetString(trusteeDN);
Asn1OctetString asn1_attrName = new Asn1OctetString(attrName);
asn1_dn.encode(encoder, encodedData);
asn1_trusteeDN.encode(encoder, encodedData);
asn1_attrName.encode(encoder, encodedData);
setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
}
catch (System.IO.IOException ioe)
{
throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
}
}
}
}

View File

@@ -0,0 +1,111 @@
/******************************************************************************
* The MIT License
* Copyright (c) 2003 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.GetEffectivePrivilegesResponse.cs
//
// Author:
// Sunil Kumar (Sunilk@novell.com)
//
// (C) 2003 Novell, Inc (http://www.novell.com)
//
using System;
using Novell.Directory.Ldap;
using Novell.Directory.Ldap.Asn1;
using Novell.Directory.Ldap.Utilclass;
using Novell.Directory.Ldap.Rfc2251;
namespace Novell.Directory.Ldap.Extensions
{
/// <summary> Retrieves the effective rights from an GetEffectivePrivilegesResponse object.
///
/// An object in this class is generated from an ExtendedResponse object
/// using the ExtendedResponseFactory class.
///
/// The getEffectivePrivilegesResponse extension uses the following OID:
/// 2.16.840.1.113719.1.27.100.34
///
/// </summary>
public class GetEffectivePrivilegesResponse:LdapExtendedResponse
{
/// <summary> Returns the effective privileges.
///
/// See the ReplicationConstants class for the privilege flags.
///
/// </summary>
/// <returns> A flag which is a combination of zero or more privilege flags as
/// returned by the server.
///
/// </returns>
virtual public int Privileges
{
get
{
return privileges;
}
}
// Identity returned by the server
private int privileges;
/// <summary> Constructs an object from the responseValue which contains the effective
/// privileges.
///
/// The constructor parses the responseValue which has the following
/// format:
/// responseValue ::=
/// privileges INTEGER
///
/// </summary>
/// <exception> IOException The responseValue could not be decoded.
/// </exception>
public GetEffectivePrivilegesResponse(RfcLdapMessage rfcMessage):base(rfcMessage)
{
if (ResultCode == LdapException.SUCCESS)
{
// parse the contents of the reply
sbyte[] returnedValue = this.Value;
if (returnedValue == null)
throw new System.IO.IOException("No returned value");
// Create a decoder object
LBERDecoder decoder = new LBERDecoder();
if (decoder == null)
throw new System.IO.IOException("Decoding error");
Asn1Integer asn1_privileges = (Asn1Integer) decoder.decode(returnedValue);
if (asn1_privileges == null)
throw new System.IO.IOException("Decoding error");
privileges = asn1_privileges.intValue();
}
else
{
privileges = 0;
}
}
}
}

View File

@@ -0,0 +1,118 @@
/******************************************************************************
* The MIT License
* Copyright (c) 2003 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.GetReplicaInfoRequest.cs
//
// Author:
// Sunil Kumar (Sunilk@novell.com)
//
// (C) 2003 Novell, Inc (http://www.novell.com)
//
using System;
using Novell.Directory.Ldap;
using Novell.Directory.Ldap.Asn1;
using Novell.Directory.Ldap.Utilclass;
namespace Novell.Directory.Ldap.Extensions
{
/// <summary>
/// Reads information about a replica.
///
/// The information available includes such items as replicas state, last
/// modification time, and replica type.
///
/// To read other information about a replica, you must
/// create an instance of this class and then call the
/// extendedOperation method with this object as the required
/// LdapExtendedOperation parameter.
///
/// The getReplicaInfoRequest extension uses the following OID:
/// 2.16.840.1.113719.1.27.100.17
///
/// The requestValue has the following format:
///
/// requestValue ::=
/// serverDN LdapDN
/// partitionDN LdapDN
/// </summary>
public class GetReplicaInfoRequest:LdapExtendedOperation
{
static GetReplicaInfoRequest()
{
/*
* Register the extendedresponse class which is returned by the
* server in response to a ListReplicasRequest
*/
try
{
LdapExtendedResponse.register(ReplicationConstants.GET_REPLICA_INFO_RES, System.Type.GetType("Novell.Directory.Ldap.Extensions.GetReplicaInfoResponse"));
}
catch (System.Exception e)
{
System.Console.Error.WriteLine("Could not register Extended Response -" + " Class not found");
}
}
/// <summary>
/// Constructs an extended operations object for reading replica information.
///
/// </summary>
/// <param name="serverDN">The server on which the replica resides.
///
/// </param>
/// <param name="partitionDN">The distinguished name of the replica to be read.
///
/// </param>
/// <exception> LdapException A general exception which includes an error
/// message and an Ldap error code.
/// </exception>
public GetReplicaInfoRequest(System.String serverDN, System.String partitionDN):base(ReplicationConstants.GET_REPLICA_INFO_REQ, null)
{
try
{
if (((System.Object) serverDN == null) || ((System.Object) partitionDN == null))
throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
LBEREncoder encoder = new LBEREncoder();
Asn1OctetString asn1_serverDN = new Asn1OctetString(serverDN);
Asn1OctetString asn1_partitionDN = new Asn1OctetString(partitionDN);
asn1_serverDN.encode(encoder, encodedData);
asn1_partitionDN.encode(encoder, encodedData);
setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
}
catch (System.IO.IOException ioe)
{
throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
}
}
}
}

View File

@@ -0,0 +1,306 @@
/******************************************************************************
* The MIT License
* Copyright (c) 2003 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.GetReplicaInfoResponse.cs
//
// Author:
// Sunil Kumar (Sunilk@novell.com)
//
// (C) 2003 Novell, Inc (http://www.novell.com)
//
using System;
using Novell.Directory.Ldap;
using Novell.Directory.Ldap.Asn1;
using Novell.Directory.Ldap.Utilclass;
using Novell.Directory.Ldap.Rfc2251;
namespace Novell.Directory.Ldap.Extensions
{
/// <summary> Retrieves the replica information from a GetReplicaInfoResponse object.
///
/// An object in this class is generated from an ExtendedResponse using the
/// ExtendedResponseFactory class.
///
/// The getReplicaInfoResponse extension uses the following OID:
/// 2.16.840.1.113719.1.27.100.18
///
/// </summary>
public class GetReplicaInfoResponse:LdapExtendedResponse
{
// Other info as returned by the server
private int partitionID;
private int replicaState;
private int modificationTime;
private int purgeTime;
private int localPartitionID;
private System.String partitionDN;
private int replicaType;
private int flags;
/// <summary> Constructs an object from the responseValue which contains the
/// replica information.
///
/// The constructor parses the responseValue which has the following
/// format:
/// responseValue ::=
/// partitionID INTEGER
/// replicaState INTEGER
/// modificationTime INTEGER
/// purgeTime INTEGER
/// localPartitionID INTEGER
/// partitionDN OCTET STRING
/// replicaType INTEGER
/// flags INTEGER
///
/// </summary>
/// <exception> IOException The response value could not be decoded.
/// </exception>
public GetReplicaInfoResponse(RfcLdapMessage rfcMessage):base(rfcMessage)
{
if (ResultCode == LdapException.SUCCESS)
{
// parse the contents of the reply
sbyte[] returnedValue = this.Value;
if (returnedValue == null)
throw new System.IO.IOException("No returned value");
// Create a decoder object
LBERDecoder decoder = new LBERDecoder();
if (decoder == null)
throw new System.IO.IOException("Decoding error");
// Parse the parameters in the order
System.IO.MemoryStream currentPtr = new System.IO.MemoryStream(SupportClass.ToByteArray(returnedValue));
// Parse partitionID
Asn1Integer asn1_partitionID = (Asn1Integer) decoder.decode(currentPtr);
if (asn1_partitionID == null)
throw new System.IO.IOException("Decoding error");
partitionID = asn1_partitionID.intValue();
// Parse replicaState
Asn1Integer asn1_replicaState = (Asn1Integer) decoder.decode(currentPtr);
if (asn1_replicaState == null)
throw new System.IO.IOException("Decoding error");
replicaState = asn1_replicaState.intValue();
// Parse modificationTime
Asn1Integer asn1_modificationTime = (Asn1Integer) decoder.decode(currentPtr);
if (asn1_modificationTime == null)
throw new System.IO.IOException("Decoding error");
modificationTime = asn1_modificationTime.intValue();
// Parse purgeTime
Asn1Integer asn1_purgeTime = (Asn1Integer) decoder.decode(currentPtr);
if (asn1_purgeTime == null)
throw new System.IO.IOException("Decoding error");
purgeTime = asn1_purgeTime.intValue();
// Parse localPartitionID
Asn1Integer asn1_localPartitionID = (Asn1Integer) decoder.decode(currentPtr);
if (asn1_localPartitionID == null)
throw new System.IO.IOException("Decoding error");
localPartitionID = asn1_localPartitionID.intValue();
// Parse partitionDN
Asn1OctetString asn1_partitionDN = (Asn1OctetString) decoder.decode(currentPtr);
if (asn1_partitionDN == null)
throw new System.IO.IOException("Decoding error");
partitionDN = asn1_partitionDN.stringValue();
if ((System.Object) partitionDN == null)
throw new System.IO.IOException("Decoding error");
// Parse replicaType
Asn1Integer asn1_replicaType = (Asn1Integer) decoder.decode(currentPtr);
if (asn1_replicaType == null)
throw new System.IO.IOException("Decoding error");
replicaType = asn1_replicaType.intValue();
// Parse flags
Asn1Integer asn1_flags = (Asn1Integer) decoder.decode(currentPtr);
if (asn1_flags == null)
throw new System.IO.IOException("Decoding error");
flags = asn1_flags.intValue();
}
else
{
partitionID = 0;
replicaState = 0;
modificationTime = 0;
purgeTime = 0;
localPartitionID = 0;
partitionDN = "";
replicaType = 0;
flags = 0;
}
}
/// <summary> Returns the numeric identifier for the partition.
///
/// </summary>
/// <returns> Integer value specifying the partition ID.
/// </returns>
public virtual int getpartitionID()
{
return partitionID;
}
/// <summary> Returns the current state of the replica.
///
/// </summary>
/// <returns> Integer value specifying the current state of the replica. See
/// ReplicationConstants class for possible values for this field.
///
/// </returns>
/// <seealso cref="ReplicationConstants.Ldap_RS_BEGIN_ADD">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RS_DEAD_REPLICA">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RS_DYING_REPLICA">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RS_JS_0">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RS_JS_1">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RS_JS_2">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RS_LOCKED">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RS_MASTER_DONE">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RS_MASTER_START">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RS_SS_0">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RS_TRANSITION_ON">
/// </seealso>
public virtual int getreplicaState()
{
return replicaState;
}
/// <summary> Returns the time of the most recent modification.
///
/// </summary>
/// <returns> Integer value specifying the last modification time.
/// </returns>
public virtual int getmodificationTime()
{
return modificationTime;
}
/// <summary> Returns the most recent time in which all data has been synchronized.
///
/// </summary>
/// <returns> Integer value specifying the last purge time.
/// </returns>
public virtual int getpurgeTime()
{
return purgeTime;
}
/// <summary> Returns the local numeric identifier for the replica.
///
/// </summary>
/// <returns> Integer value specifying the local ID of the partition.
/// </returns>
public virtual int getlocalPartitionID()
{
return localPartitionID;
}
/// <summary> Returns the distinguished name of the partition.
///
/// </summary>
/// <returns> String value specifying the name of the partition read.
/// </returns>
public virtual System.String getpartitionDN()
{
return partitionDN;
}
/// <summary> Returns the replica type.
///
/// See the ReplicationConstants class for possible values for
/// this field.
///
/// </summary>
/// <returns> Integer identifying the type of the replica.
///
/// </returns>
/// <seealso cref="ReplicationConstants.Ldap_RT_MASTER">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RT_SECONDARY">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RT_READONLY">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RT_SUBREF">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RT_SPARSE_WRITE">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_RT_SPARSE_READ">
/// </seealso>
public virtual int getreplicaType()
{
return replicaType;
}
/// <summary> Returns flags that specify whether the replica is busy or is a boundary.
///
/// See the ReplicationConstants class for possible values for
/// this field.
///
/// </summary>
/// <returns> Integer value specifying the flags for the replica.
///
/// </returns>
/// <seealso cref="ReplicationConstants.Ldap_DS_FLAG_BUSY">
/// </seealso>
/// <seealso cref="ReplicationConstants.Ldap_DS_FLAG_BOUNDARY">
/// </seealso>
public virtual int getflags()
{
return flags;
}
}
}

View File

@@ -0,0 +1,112 @@
/******************************************************************************
* The MIT License
* Copyright (c) 2003 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.GetReplicationFilterRequest.cs
//
// Author:
// Sunil Kumar (Sunilk@novell.com)
//
// (C) 2003 Novell, Inc (http://www.novell.com)
//
using System;
using Novell.Directory.Ldap;
using Novell.Directory.Ldap.Asn1;
using Novell.Directory.Ldap.Utilclass;
namespace Novell.Directory.Ldap.Extensions
{
/// <summary>
/// Gets the Replication filter for all replicas on the server.
///
/// The filter is returned as an array of classnames-attribute names pairs.
///
/// To get the filter for all replicas on a specific server, you must
/// create an instance of this class and then call the
/// extendedOperation method with this object as the required
/// LdapExtendedOperation parameter.
///
/// The GetReplicationFilterRequest extension uses the following OID:
/// 2.16.840.1.113719.1.27.100.37
///
/// The requestValue has the following format:
///
/// requestValue ::=
/// serverName LdapDN
/// </summary>
public class GetReplicationFilterRequest:LdapExtendedOperation
{
static GetReplicationFilterRequest()
{
/*
* Register the extendedresponse class which is returned by the
* server in response to a ListReplicasRequest
*/
try
{
LdapExtendedResponse.register(ReplicationConstants.GET_REPLICATION_FILTER_RES, System.Type.GetType("Novell.Directory.Ldap.Extensions.GetReplicationFilterResponse"));
}
catch (System.Exception e)
{
System.Console.Error.WriteLine("Could not register Extended Response -" + " Class not found");
}
}
/// <summary>
/// Constructs an extended operations object which contains the ber encoded
/// replication filter.
///
/// </summary>
/// <param name="serverDN">The server whose replication filter needs to be read
///
/// </param>
/// <exception> LdapException A general exception which includes an error
/// message and an Ldap error code.
/// </exception>
public GetReplicationFilterRequest(System.String serverDN):base(ReplicationConstants.GET_REPLICATION_FILTER_REQ, null)
{
try
{
if ((System.Object) serverDN == null)
throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
LBEREncoder encoder = new LBEREncoder();
Asn1OctetString asn1_serverDN = new Asn1OctetString(serverDN);
// Add the serverDN to encoded data
asn1_serverDN.encode(encoder, encodedData);
setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
}
catch (System.IO.IOException ioe)
{
throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
}
}
}
}

View File

@@ -0,0 +1,165 @@
/******************************************************************************
* The MIT License
* Copyright (c) 2003 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.GetReplicationFilterResponse.cs
//
// Author:
// Sunil Kumar (Sunilk@novell.com)
//
// (C) 2003 Novell, Inc (http://www.novell.com)
//
using System;
using Novell.Directory.Ldap;
using Novell.Directory.Ldap.Asn1;
using Novell.Directory.Ldap.Utilclass;
using Novell.Directory.Ldap.Rfc2251;
namespace Novell.Directory.Ldap.Extensions
{
/// <summary> This object represent the filter returned fom a GetReplicationFilterRequest.
///
/// An object in this class is generated from an ExtendedResponse object
/// using the ExtendedResponseFactory class.
///
/// The GetReplicationFilterResponse extension uses the following OID:
/// 2.16.840.1.113719.1.27.100.38
///
/// </summary>
public class GetReplicationFilterResponse:LdapExtendedResponse
{
/// <summary> Returns the replicationFilter as an array of classname-attribute name pairs
///
/// </summary>
/// <returns> String array contining a two dimensional array of strings. The first
/// element of each array is the class name the others are the attribute names
/// </returns>
virtual public System.String[][] ReplicationFilter
{
get
{
return returnedFilter;
}
}
// Replication filter returned by the server goes here
internal System.String[][] returnedFilter;
/// <summary> Constructs an object from the responseValue which contains the replication
/// filter.
///
/// The constructor parses the responseValue which has the following
/// format:
/// responseValue ::=
/// SEQUENCE of SEQUENCE {
/// classname OCTET STRING
/// SEQUENCE of ATTRIBUTES
/// }
/// where
/// ATTRIBUTES:: OCTET STRING
///
/// </summary>
/// <exception> IOException The responseValue could not be decoded.
/// </exception>
public GetReplicationFilterResponse(RfcLdapMessage rfcMessage):base(rfcMessage)
{
if (ResultCode != LdapException.SUCCESS)
{
returnedFilter = new System.String[0][];
for (int i = 0; i < 0; i++)
{
returnedFilter[i] = new System.String[0];
}
}
else
{
// parse the contents of the reply
sbyte[] returnedValue = this.Value;
if (returnedValue == null)
throw new System.IO.IOException("No returned value");
// Create a decoder object
LBERDecoder decoder = new LBERDecoder();
if (decoder == null)
throw new System.IO.IOException("Decoding error");
// We should get back a sequence
Asn1Sequence returnedSequence = (Asn1Sequence) decoder.decode(returnedValue);
if (returnedSequence == null)
throw new System.IO.IOException("Decoding error");
// How many sequences in this list
int numberOfSequences = returnedSequence.size();
returnedFilter = new System.String[numberOfSequences][];
// Parse each returned sequence object
for (int classNumber = 0; classNumber < numberOfSequences; classNumber++)
{
// Get the next Asn1Sequence
Asn1Sequence asn1_innerSequence = (Asn1Sequence) returnedSequence.get_Renamed(classNumber);
if (asn1_innerSequence == null)
throw new System.IO.IOException("Decoding error");
// Get the asn1 encoded classname
Asn1OctetString asn1_className = (Asn1OctetString) asn1_innerSequence.get_Renamed(0);
if (asn1_className == null)
return ;
// Get the attribute List
Asn1Sequence asn1_attributeList = (Asn1Sequence) asn1_innerSequence.get_Renamed(1);
if (asn1_attributeList == null)
throw new System.IO.IOException("Decoding error");
int numberOfAttributes = asn1_attributeList.size();
returnedFilter[classNumber] = new System.String[numberOfAttributes + 1];
// Get the classname
returnedFilter[classNumber][0] = asn1_className.stringValue();
if ((System.Object) returnedFilter[classNumber][0] == null)
throw new System.IO.IOException("Decoding error");
for (int attributeNumber = 0; attributeNumber < numberOfAttributes; attributeNumber++)
{
// Get the asn1 encoded attribute name
Asn1OctetString asn1_attributeName = (Asn1OctetString) asn1_attributeList.get_Renamed(attributeNumber);
if (asn1_attributeName == null)
throw new System.IO.IOException("Decoding error");
// Get attributename string
returnedFilter[classNumber][attributeNumber + 1] = asn1_attributeName.stringValue();
if ((System.Object) returnedFilter[classNumber][attributeNumber + 1] == null)
throw new System.IO.IOException("Decoding error");
}
}
}
}
}
}

View File

@@ -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);
}
}
}
}

View File

@@ -0,0 +1,263 @@
/******************************************************************************
* 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;
using Novell.Directory.Ldap.Rfc2251;
/**
* This object represent the data returned from a LdapBackupRequest.
*
* <p>An object in this class is generated from an ExtendedResponse object
* using the ExtendedResponseFactory class.</p>
*
* <p>The LdapBackupResponse extension uses the following OID:<br>
* &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.97</p>
*
*/
namespace Novell.Directory.Ldap.Extensions
{
public class LdapBackupResponse:LdapExtendedResponse
{
private int bufferLength; //Represents the length of backup data
private String stateInfo; //Represent the state Information of data
/*
* The String representing the number of chunks and each elements in chunk
* array as returned by server.
* Data from server is parsed as follows before sending to any Application::
* no_of_chunks;sizeOf(chunk1);sizeOf(chunk2)<29>sizeOf(chunkn)
* where
* no_of_chunks => Represents the number of chunks of data returned from server
* sizeOf(chunkn) => Represents the size of data in chunkn
*/
private String chunkSizesString;
/*
* Actual data of returned eDirectoty Object in byte[]
*/
private byte[] returnedBuffer;
/**
* Constructs an object from the responseValue which contains the backup data.
* <p>The constructor parses the responseValue which has the following
* format:<br>
* responseValue ::=<br>
* <p>databufferLength ::= INTEGER <br>
* mts(modification time stamp) ::= INTEGER<br>
* revision ::= INTEGER<br>
* returnedBuffer ::= OCTET STRING<br>
* dataChunkSizes ::= <br>
* SEQUENCE{<br>
* noOfChunks INTEGER<br>
* SET of [<br>
* SEQUENCE of {eachChunksize INTEGER}]<br>
* }</p>
*
* @exception IOException The responseValue could not be decoded.
*/
public LdapBackupResponse(RfcLdapMessage rfcMessage): base(rfcMessage)
{
int modificationTime = 0; // Modifaction timestamp of the Object
int revision = 0; // Revision number of the Object
int chunksSize = 0;
int[] chunks = null; //Holds size of each chunks returned from server
//Verify if returned ID is not proper
if (ID == null || !(ID.Equals(BackupRestoreConstants.NLDAP_LDAP_BACKUP_RESPONSE)))
throw new IOException("LDAP Extended Operation not supported");
if (ResultCode == LdapException.SUCCESS) {
// Get the contents of the reply
byte[] returnedValue = SupportClass.ToByteArray(this.Value);
if (returnedValue == null)
throw new Exception("LDAP Operations error. No returned value.");
// Create a decoder object
LBERDecoder decoder = new LBERDecoder();
if (decoder == null)
throw new Exception("Decoding error");
// Parse the parameters in the order
MemoryStream currentPtr = new MemoryStream(returnedValue);
// Parse bufferLength
Asn1Integer asn1_bufferLength = (Asn1Integer) decoder
.decode(currentPtr);
if (asn1_bufferLength == null)
throw new IOException("Decoding error");
bufferLength = asn1_bufferLength.intValue();
// Parse modificationTime
Asn1Integer asn1_modificationTime = (Asn1Integer) decoder
.decode(currentPtr);
if (asn1_modificationTime == null)
throw new IOException("Decoding error");
modificationTime = asn1_modificationTime.intValue();
// Parse revision
Asn1Integer asn1_revision = (Asn1Integer) decoder
.decode(currentPtr);
if (asn1_revision == null)
throw new IOException("Decoding error");
revision = asn1_revision.intValue();
//Format stateInfo to contain both modificationTime and revision
this.stateInfo = modificationTime + "+" + revision;
// Parse returnedBuffer
Asn1OctetString asn1_returnedBuffer = (Asn1OctetString) decoder.decode(currentPtr);
if (asn1_returnedBuffer == null)
throw new IOException("Decoding error");
returnedBuffer = SupportClass.ToByteArray(asn1_returnedBuffer.byteValue());
/*
* Parse chunks array
* Chunks returned from server is encoded as shown below::
* SEQUENCE{
* chunksSize INTEGER
* SET of [
* SEQUENCE of {eacChunksize INTEGER}]
* }
*/
Asn1Sequence asn1_chunksSeq = (Asn1Sequence) decoder
.decode(currentPtr);
if (asn1_chunksSeq == null)
throw new IOException("Decoding error");
//Get number of chunks returned from server
chunksSize = ((Asn1Integer)asn1_chunksSeq.get_Renamed(0)).intValue();
//Construct chunks array
chunks = new int[chunksSize];
Asn1Set asn1_chunksSet = (Asn1Set)asn1_chunksSeq.get_Renamed(1);
//Iterate through asn1_chunksSet and put each size into chunks array
for (int index = 0; index < chunksSize; index++)
{
Asn1Sequence asn1_eachSeq = (Asn1Sequence)asn1_chunksSet.get_Renamed(index);
chunks[index] = ((Asn1Integer)asn1_eachSeq.get_Renamed(0)).intValue();
}
//Construct a temporary StringBuffer and append chunksSize, each size
//element in chunks array and actual data of eDirectoty Object
System.Text.StringBuilder tempBuffer = new System.Text.StringBuilder();
tempBuffer.Append(chunksSize);
tempBuffer.Append(";");
int i = 0;
for (; i < (chunksSize - 1); i++)
{
tempBuffer.Append(chunks[i]);
tempBuffer.Append(";");
}
tempBuffer.Append(chunks[i]);
//Assign tempBuffer to parsedString to be returned to Application
this.chunkSizesString = tempBuffer.ToString();
}
else
{
//Intialize all these if getResultCode() != LdapException.SUCCESS
this.bufferLength = 0;
this.stateInfo = null;
this.chunkSizesString = null;
this.returnedBuffer = null;
}
}
/**
* Returns the data buffer length
*
* @return bufferLength as integer.
*/
public int getBufferLength()
{
return bufferLength;
}
/**
* Returns the stateInfo of returned eDirectory Object.
* This is combination of MT (Modification Timestamp) and
* Revision value with char '+' as separator between two.<br>
* Client application if want to use both MT and Revision need to break
* this string to get both these data.
*
* @return stateInfo as String.
*/
public String getStatusInfo()
{
return stateInfo;
}
/**
* Returns the data in String as::<br>
* no_of_chunks;sizeOf(chunk1);sizeOf(chunk2)<29>sizeOf(chunkn)<br>
* where<br>
* no_of_chunks => Represents the number of chunks of data returned from server<br>
* sizeOf(chunkn) => Represents the size of data in chunkn<br>
*
* @return chunkSizesString as String.
*/
public String getChunkSizesString()
{
return chunkSizesString;
}
/**
* Returns the data buffer as byte[]
*
* @return returnedBuffer as byte[].
*/
public byte[] getReturnedBuffer()
{
return returnedBuffer;
}
}
}

View File

@@ -0,0 +1,197 @@
/******************************************************************************
* 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
* restore of eDirectory objects.
*
* <p>The information need for restore includes such items as object DN,
* data buffer length, string containing the number of chunks and each chunk
* elements representing the size of each chunk, data blob in byte[]. The API
* support restoring of both non-encrypted and encrypted objects.
* </p>
*
* <p>To send this request to eDirectory, you must
* create an instance of this class and then call the
* extendedOperation method with this object as the required
* LdapExtendedOperation parameter.</p><br>
*
* <p>The getLdapRestoreRequest extension uses the following OID:<br>
* &nbsp;&nbsp;&nbsp;2.16.840.1.113719.1.27.100.98</p><br>
*
* <p>The requestValue has the following format:<br>
*
* <p>requestValue ::=<br>
* objectDN ::= LDAPDN<br>
* passwd ::= OCTET STRING<br>
* bufferLength ::= INTEGER<br>
* retunedBuffer::= OCTET STRING<br>
* dataChunkSizes ::=<br>
* SEQUENCE {<br>
* noOfChunks INTEGER<br>
* SET of [<br>
* SEQUENCE of {eacChunksize INTEGER}]<br>
* }<br> </p>
*/
namespace Novell.Directory.Ldap.Extensions
{
public class LdapRestoreRequest : LdapExtendedOperation
{
/**
*
* Constructs an extended operations object which contains the ber encoded
* restore data.
*
* @param objectDN The object DN to restore
* <br>
* @param passwd The encrypted password required for the object to
* be backed up
* <br>
* @param bufferLength The length of backed up data
* <br>
* @param chunkSizesString The String containing number of chunks and
* each chunk elements representing chunk sizes
* <br>
* @param returnedBuffer The actual data in byte[]
* <br><br>
* @exception LdapException A general exception which includes an error
* message and an LDAP error code.
*/
public LdapRestoreRequest(String objectDN, byte[] passwd,
int bufferLength, String chunkSizesString, byte[] returnedBuffer):
base(BackupRestoreConstants.NLDAP_LDAP_RESTORE_REQUEST, null)
{
try
{
//Verify the validity of arguments
if (objectDN == null || bufferLength == 0 ||
chunkSizesString == null || returnedBuffer == 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("");
/*
* From the input argument chunkSizesString get::
* chunkSize => Represents the number of chunks of data returned from server
* sizeOf each chunk => int represents the size of each chunk
*/
int index;
int chunkSize;
int[] chunks = null;
index = chunkSizesString.IndexOf(';');
try
{
chunkSize = int.Parse(chunkSizesString.Substring(0, index));
}
catch (FormatException e)
{
throw new LdapLocalException(
"Invalid data buffer send in the request",
LdapException.ENCODING_ERROR);
}
//Return exception if chunkSize == 0
if (chunkSize == 0)
throw new ArgumentException("PARAM_ERROR");
chunkSizesString = chunkSizesString.Substring(index + 1);
int chunkIndex;
//Construct chunks array
chunks = new int[chunkSize];
/*
* Iterate through each member in buffer and
* assign to chunks array elements
*/
for (int i = 0; i < chunkSize; i++)
{
chunkIndex = chunkSizesString.IndexOf(';');
if(chunkIndex == -1)
{
chunks[i] = int.Parse(chunkSizesString);
break;
}
chunks[i] = int.Parse(chunkSizesString.Substring(0,
chunkIndex));
chunkSizesString = chunkSizesString.Substring(chunkIndex + 1);
}
MemoryStream encodedData = new MemoryStream();
LBEREncoder encoder = new LBEREncoder();
//Form objectDN, passwd, bufferLength, data byte[] as ASN1 Objects
Asn1OctetString asn1_objectDN = new Asn1OctetString(objectDN);
Asn1OctetString asn1_passwd = new Asn1OctetString(SupportClass.ToSByteArray(passwd));
Asn1Integer asn1_bufferLength = new Asn1Integer(bufferLength);
Asn1OctetString asn1_buffer = new Asn1OctetString(SupportClass.ToSByteArray(returnedBuffer));
//Form the chunks sequence to be passed to Server
Asn1Sequence asn1_chunksSeq = new Asn1Sequence();
asn1_chunksSeq.add(new Asn1Integer(chunkSize));
Asn1Set asn1_chunksSet = new Asn1Set();
for (int i = 0; i < chunkSize; i++)
{
Asn1Integer tmpChunk = new Asn1Integer(chunks[i]);
Asn1Sequence tmpSeq = new Asn1Sequence();
tmpSeq.add(tmpChunk);
asn1_chunksSet.add(tmpSeq);
}
asn1_chunksSeq.add(asn1_chunksSet);
//Encode data to send to server
asn1_objectDN.encode(encoder, encodedData);
asn1_passwd.encode(encoder, encodedData);
asn1_bufferLength.encode(encoder, encodedData);
asn1_buffer.encode(encoder, encodedData);
asn1_chunksSeq.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);
}
}
}
}

View File

@@ -0,0 +1,105 @@
/******************************************************************************
* The MIT License
* Copyright (c) 2003 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.ListReplicasRequest.cs
//
// Author:
// Sunil Kumar (Sunilk@novell.com)
//
// (C) 2003 Novell, Inc (http://www.novell.com)
//
using System;
using Novell.Directory.Ldap;
using Novell.Directory.Ldap.Asn1;
using Novell.Directory.Ldap.Utilclass;
namespace Novell.Directory.Ldap.Extensions
{
/// <summary>
/// Lists all the replicas that reside on the the specified directory server.
///
/// To list replicas, you must create an instance
/// of this class and then call the extendedOperation method with this
/// object as the required LdapExtendedOperation parameter.
///
/// The listReplicaRequest extension uses the following OID:
/// 2.16.840.1.113719.1.27.100.19
///
/// The requestValue has the following format:
///
/// requestValue ::=
/// serverName LdapDN
/// </summary>
public class ListReplicasRequest:LdapExtendedOperation
{
static ListReplicasRequest()
{
/*
* Register the extendedresponse class which is returned by the
* server in response to a ListReplicasRequest
*/
try
{
LdapExtendedResponse.register(ReplicationConstants.LIST_REPLICAS_RES, System.Type.GetType("Novell.Directory.Ldap.Extensions.ListReplicasResponse"));
}
catch (System.Exception e)
{
System.Console.Error.WriteLine("Could not register Extended Response -" + " Class not found");
}
}
/// <summary> Constructs an extended operation object for listing replicas.
///
/// </summary>
/// <param name="serverName">The server which contains replicas.
///
/// </param>
/// <exception> LdapException A general exception which includes an error
/// message and an Ldap error code.
/// </exception>
public ListReplicasRequest(System.String serverName):base(ReplicationConstants.LIST_REPLICAS_REQ, null)
{
try
{
if ((System.Object) serverName == null)
throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
LBEREncoder encoder = new LBEREncoder();
Asn1OctetString asn1_serverName = new Asn1OctetString(serverName);
asn1_serverName.encode(encoder, encodedData);
setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
}
catch (System.IO.IOException ioe)
{
throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
}
}
}
}

View File

@@ -0,0 +1,125 @@
/******************************************************************************
* The MIT License
* Copyright (c) 2003 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.ListReplicasResponse.cs
//
// Author:
// Sunil Kumar (Sunilk@novell.com)
//
// (C) 2003 Novell, Inc (http://www.novell.com)
//
using System;
using Novell.Directory.Ldap;
using Novell.Directory.Ldap.Asn1;
using Novell.Directory.Ldap.Utilclass;
using Novell.Directory.Ldap.Rfc2251;
namespace Novell.Directory.Ldap.Extensions
{
/// <summary> Retrieves the list of replicas from the specified server.
///
/// An object in this class is generated from an ExtendedResponse object
/// using the ExtendedResponseFactory class.
///
/// The listReplicaResponse extension uses the following OID:
/// 2.16.840.1.113719.1.27.20
///
/// </summary>
public class ListReplicasResponse:LdapExtendedResponse
{
/// <summary> Returns a list of distinguished names for the replicas on the server.
///
/// </summary>
/// <returns> String value specifying the identity returned by the server
/// </returns>
virtual public System.String[] ReplicaList
{
get
{
return replicaList;
}
}
// Identity returned by the server
private System.String[] replicaList;
/// <summary> Constructs an object from the responseValue which contains the list
/// of replicas.
///
/// The constructor parses the responseValue which has the following
/// format:
/// responseValue ::=
/// replicaList
/// SEQUENCE OF OCTET STRINGS
///
/// </summary>
/// <exception> IOException The responseValue could not be decoded.
/// </exception>
public ListReplicasResponse(RfcLdapMessage rfcMessage):base(rfcMessage)
{
if (ResultCode != LdapException.SUCCESS)
{
replicaList = new System.String[0];
}
else
{
// parse the contents of the reply
sbyte[] returnedValue = this.Value;
if (returnedValue == null)
throw new System.IO.IOException("No returned value");
// Create a decoder object
LBERDecoder decoder = new LBERDecoder();
if (decoder == null)
throw new System.IO.IOException("Decoding error");
// We should get back a sequence
Asn1Sequence returnedSequence = (Asn1Sequence) decoder.decode(returnedValue);
if (returnedSequence == null)
throw new System.IO.IOException("Decoding error");
// How many replicas were returned
int len = returnedSequence.size();
replicaList = new System.String[len];
// Copy each one into our String array
for (int i = 0; i < len; i++)
{
// Get the next Asn1Octet String in the sequence
Asn1OctetString asn1_nextReplica = (Asn1OctetString) returnedSequence.get_Renamed(i);
if (asn1_nextReplica == null)
throw new System.IO.IOException("Decoding error");
// Convert to a string
replicaList[i] = asn1_nextReplica.stringValue();
if ((System.Object) replicaList[i] == null)
throw new System.IO.IOException("Decoding error");
}
}
}
}
}

View File

@@ -0,0 +1,102 @@
/******************************************************************************
* The MIT License
* Copyright (c) 2003 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.MergePartitionsRequest.cs
//
// Author:
// Sunil Kumar (Sunilk@novell.com)
//
// (C) 2003 Novell, Inc (http://www.novell.com)
//
using System;
using Novell.Directory.Ldap;
using Novell.Directory.Ldap.Asn1;
using Novell.Directory.Ldap.Utilclass;
namespace Novell.Directory.Ldap.Extensions
{
/// <summary>
/// Merges a child partition with its parent partition.
///
/// To merge a child partition with its parent, you must create an
/// instance of this class and then call the extendedOperation method
/// with this object as the required LdapExtendedOperation parameter.
///
/// The mergePartitionsRequest extension uses the following OID:
/// 2.16.840.1.113719.1.27.100.5
///
/// The requestValue has the following format:
///
/// requestValue ::=
/// flags INTEGER
/// dn LdapDN
/// </summary>
public class MergePartitionsRequest:LdapExtendedOperation
{
/// <summary> Constructs an extended operation object for merging partitions.
///
/// </summary>
/// <param name="dn"> The distinguished name of the child partition's root.
///
/// </param>
/// <param name="flags"> Determines whether all servers in the replica ring must
/// be up before proceeding. When set to zero, the status of
/// the servers is not checked. When set to
/// Ldap_ENSURE_SERVERS_UP, all servers must be up for the
/// operation to proceed.
///
/// </param>
/// <exception> LdapException A general exception which includes an error
/// message and an Ldap error code.
/// </exception>
public MergePartitionsRequest(System.String dn, int flags):base(ReplicationConstants.MERGE_NAMING_CONTEXT_REQ, null)
{
try
{
if ((System.Object) dn == null)
throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
LBEREncoder encoder = new LBEREncoder();
Asn1Integer asn1_flags = new Asn1Integer(flags);
Asn1OctetString asn1_dn = new Asn1OctetString(dn);
asn1_flags.encode(encoder, encodedData);
asn1_dn.encode(encoder, encodedData);
setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
}
catch (System.IO.IOException ioe)
{
throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
}
}
}
}

View File

@@ -0,0 +1,367 @@
/******************************************************************************
* The MIT License
* Copyright (c) 2003 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.NamingContextConstants.cs
//
// Author:
// Sunil Kumar (Sunilk@novell.com)
//
// (C) 2003 Novell, Inc (http://www.novell.com)
//
using System;
namespace Novell.Directory.Ldap.Extensions
{
/*
* public class NamingContextConstants
*/
/// <summary> Contains a collection of constants used by the Novell Ldap extensions.</summary>
public class NamingContextConstants
{
/// <summary> A constant for the createNamingContextRequest OID.</summary>
public const System.String CREATE_NAMING_CONTEXT_REQ = "2.16.840.1.113719.1.27.100.3";
/// <summary> A constant for the createNamingContextResponse OID.</summary>
public const System.String CREATE_NAMING_CONTEXT_RES = "2.16.840.1.113719.1.27.100.4";
/// <summary> A constant for the mergeNamingContextRequest OID.</summary>
public const System.String MERGE_NAMING_CONTEXT_REQ = "2.16.840.1.113719.1.27.100.5";
/// <summary> A constant for the mergeNamingContextResponse OID.</summary>
public const System.String MERGE_NAMING_CONTEXT_RES = "2.16.840.1.113719.1.27.100.6";
/// <summary> A constant for the addReplicaRequest OID.</summary>
public const System.String ADD_REPLICA_REQ = "2.16.840.1.113719.1.27.100.7";
/// <summary> A constant for the addReplicaResponse OID.</summary>
public const System.String ADD_REPLICA_RES = "2.16.840.1.113719.1.27.100.8";
/// <summary> A constant for the refreshServerRequest OID.</summary>
public const System.String REFRESH_SERVER_REQ = "2.16.840.1.113719.1.27.100.9";
/// <summary> A constant for the refreshServerResponse OID.</summary>
public const System.String REFRESH_SERVER_RES = "2.16.840.1.113719.1.27.100.10";
/// <summary> A constant for the removeReplicaRequest OID.</summary>
public const System.String DELETE_REPLICA_REQ = "2.16.840.1.113719.1.27.100.11";
/// <summary> A constant for the removeReplicaResponse OID.</summary>
public const System.String DELETE_REPLICA_RES = "2.16.840.1.113719.1.27.100.12";
/// <summary> A constant for the namingContextEntryCountRequest OID.</summary>
public const System.String NAMING_CONTEXT_COUNT_REQ = "2.16.840.1.113719.1.27.100.13";
/// <summary> A constant for the namingContextEntryCountResponse OID.</summary>
public const System.String NAMING_CONTEXT_COUNT_RES = "2.16.840.1.113719.1.27.100.14";
/// <summary> A constant for the changeReplicaTypeRequest OID.</summary>
public const System.String CHANGE_REPLICA_TYPE_REQ = "2.16.840.1.113719.1.27.100.15";
/// <summary> A constant for the changeReplicaTypeResponse OID.</summary>
public const System.String CHANGE_REPLICA_TYPE_RES = "2.16.840.1.113719.1.27.100.16";
/// <summary> A constant for the getReplicaInfoRequest OID.</summary>
public const System.String GET_REPLICA_INFO_REQ = "2.16.840.1.113719.1.27.100.17";
/// <summary> A constant for the getReplicaInfoResponse OID.</summary>
public const System.String GET_REPLICA_INFO_RES = "2.16.840.1.113719.1.27.100.18";
/// <summary> A constant for the listReplicaRequest OID.</summary>
public const System.String LIST_REPLICAS_REQ = "2.16.840.1.113719.1.27.100.19";
/// <summary> A constant for the listReplicaResponse OID.</summary>
public const System.String LIST_REPLICAS_RES = "2.16.840.1.113719.1.27.100.20";
/// <summary> A constant for the receiveAllUpdatesRequest OID.</summary>
public const System.String RECEIVE_ALL_UPDATES_REQ = "2.16.840.1.113719.1.27.100.21";
/// <summary> A constant for the receiveAllUpdatesResponse OID.</summary>
public const System.String RECEIVE_ALL_UPDATES_RES = "2.16.840.1.113719.1.27.100.22";
/// <summary> A constant for the sendAllUpdatesRequest OID.</summary>
public const System.String SEND_ALL_UPDATES_REQ = "2.16.840.1.113719.1.27.100.23";
/// <summary> A constant for the sendAllUpdatesResponse OID.</summary>
public const System.String SEND_ALL_UPDATES_RES = "2.16.840.1.113719.1.27.100.24";
/// <summary> A constant for the requestNamingContextSyncRequest OID.</summary>
public const System.String NAMING_CONTEXT_SYNC_REQ = "2.16.840.1.113719.1.27.100.25";
/// <summary> A constant for the requestNamingContextSyncResponse OID.</summary>
public const System.String NAMING_CONTEXT_SYNC_RES = "2.16.840.1.113719.1.27.100.26";
/// <summary> A constant for the requestSchemaSyncRequest OID.</summary>
public const System.String SCHEMA_SYNC_REQ = "2.16.840.1.113719.1.27.100.27";
/// <summary> A constant for the requestSchemaSyncResponse OID.</summary>
public const System.String SCHEMA_SYNC_RES = "2.16.840.1.113719.1.27.100.28";
/// <summary> A constant for the abortNamingContextOperationRequest OID.</summary>
public const System.String ABORT_NAMING_CONTEXT_OP_REQ = "2.16.840.1.113719.1.27.100.29";
/// <summary> A constant for the abortNamingContextOperationResponse OID.</summary>
public const System.String ABORT_NAMING_CONTEXT_OP_RES = "2.16.840.1.113719.1.27.100.30";
/// <summary> A constant for the getContextIdentityNameRequest OID.</summary>
public const System.String GET_IDENTITY_NAME_REQ = "2.16.840.1.113719.1.27.100.31";
/// <summary> A constant for the getContextIdentityNameResponse OID.</summary>
public const System.String GET_IDENTITY_NAME_RES = "2.16.840.1.113719.1.27.100.32";
/// <summary> A constant for the getEffectivePrivilegesRequest OID.</summary>
public const System.String GET_EFFECTIVE_PRIVILEGES_REQ = "2.16.840.1.113719.1.27.100.33";
/// <summary> A constant for the getEffectivePrivilegesResponse OID.</summary>
public const System.String GET_EFFECTIVE_PRIVILEGES_RES = "2.16.840.1.113719.1.27.100.34";
/// <summary> A constant for the setReplicationFilterRequest OID.</summary>
public const System.String SET_REPLICATION_FILTER_REQ = "2.16.840.1.113719.1.27.100.35";
/// <summary> A constant for the setReplicationFilterResponse OID.</summary>
public const System.String SET_REPLICATION_FILTER_RES = "2.16.840.1.113719.1.27.100.36";
/// <summary> A constant for the getReplicationFilterRequest OID.</summary>
public const System.String GET_REPLICATION_FILTER_REQ = "2.16.840.1.113719.1.27.100.37";
/// <summary> A constant for the getReplicationFilterResponse OID.</summary>
public const System.String GET_REPLICATION_FILTER_RES = "2.16.840.1.113719.1.27.100.38";
/// <summary> A constant for the createOrphanNamingContextRequest OID.</summary>
public const System.String CREATE_ORPHAN_NAMING_CONTEXT_REQ = "2.16.840.1.113719.1.27.100.39";
/// <summary> A constant for the createOrphanNamingContextResponse OID.</summary>
public const System.String CREATE_ORPHAN_NAMING_CONTEXT_RES = "2.16.840.1.113719.1.27.100.40";
/// <summary> A constant for the removeOrphanNamingContextRequest OID.</summary>
public const System.String REMOVE_ORPHAN_NAMING_CONTEXT_REQ = "2.16.840.1.113719.1.27.100.41";
/// <summary> A constant for the removeOrphanNamingContextResponse OID.</summary>
public const System.String REMOVE_ORPHAN_NAMING_CONTEXT_RES = "2.16.840.1.113719.1.27.100.42";
/// <summary> A constant for the triggerBackLinkerRequest OID.</summary>
public const System.String TRIGGER_BKLINKER_REQ = "2.16.840.1.113719.1.27.100.43";
/// <summary> A constant for the triggerBackLinkerResponse OID.</summary>
public const System.String TRIGGER_BKLINKER_RES = "2.16.840.1.113719.1.27.100.44";
/// <summary> A constant for the triggerJanitorRequest OID.</summary>
public const System.String TRIGGER_JANITOR_REQ = "2.16.840.1.113719.1.27.100.47";
/// <summary> A constant for the triggerJanitorResponse OID.</summary>
public const System.String TRIGGER_JANITOR_RES = "2.16.840.1.113719.1.27.100.48";
/// <summary> A constant for the triggerLimberRequest OID.</summary>
public const System.String TRIGGER_LIMBER_REQ = "2.16.840.1.113719.1.27.100.49";
/// <summary> A constant for the triggerLimberResponse OID.</summary>
public const System.String TRIGGER_LIMBER_RES = "2.16.840.1.113719.1.27.100.50";
/// <summary> A constant for the triggerSkulkerRequest OID.</summary>
public const System.String TRIGGER_SKULKER_REQ = "2.16.840.1.113719.1.27.100.51";
/// <summary> A constant for the triggerSkulkerResponse OID.</summary>
public const System.String TRIGGER_SKULKER_RES = "2.16.840.1.113719.1.27.100.52";
/// <summary> A constant for the triggerSchemaSyncRequest OID.</summary>
public const System.String TRIGGER_SCHEMA_SYNC_REQ = "2.16.840.1.113719.1.27.100.53";
/// <summary> A constant for the triggerSchemaSyncResponse OID.</summary>
public const System.String TRIGGER_SCHEMA_SYNC_RES = "2.16.840.1.113719.1.27.100.54";
/// <summary> A constant for the triggerPartitionPurgeRequest OID.</summary>
public const System.String TRIGGER_PART_PURGE_REQ = "2.16.840.1.113719.1.27.100.55";
/// <summary> A constant for the triggerPartitionPurgeResponse OID.</summary>
public const System.String TRIGGER_PART_PURGE_RES = "2.16.840.1.113719.1.27.100.56";
/// <summary> A constant that specifies that all servers in a replica ring must be
/// running for a naming context operation to proceed.
/// </summary>
public const int Ldap_ENSURE_SERVERS_UP = 1;
/// <summary> Identifies this replica as the master replica of the naming context.
///
/// On this type of replica, entries can be modified, and naming context
/// operations can be performed.
/// </summary>
public const int Ldap_RT_MASTER = 0;
/// <summary> Identifies this replica as a secondary replica of the naming context.
///
/// On this type of replica, read and write operations can be performed,
/// and entries can be modified.
/// </summary>
public const int Ldap_RT_SECONDARY = 1;
/// <summary> Identifies this replica as a read-only replica of the naming context.
///
/// Only Novell eDirectory synchronization processes can modifie
/// entries on this replica.
/// </summary>
public const int Ldap_RT_READONLY = 2;
/// <summary> Identifies this replica as a subordinate reference replica of the
/// naming context.
///
/// Novell eDirectory automatically adds these replicas to a server
/// when the server does not contain replicas of all child naming contexts.
/// Only eDirectory can modify information on these types of replicas.
/// </summary>
public const int Ldap_RT_SUBREF = 3;
/// <summary> Identifies this replica as a read/write replica of the naming context,
/// but the replica contains sparse data.
///
/// The replica has been configured to contain only specified object types
/// and attributes. On this type of replica, only the attributes and objects
/// contained in the sparse data can be modified.
/// </summary>
public const int Ldap_RT_SPARSE_WRITE = 4;
/// <summary> Identifies this replica as a read-only replica of the naming context,
/// but the replica contains sparse data.
///
/// The replica has been configured to contain only specified object types
/// and attributes. On this type of replica, only Novell eDirectory
/// synchronization processes can modify the sparse data.
/// </summary>
public const int Ldap_RT_SPARSE_READ = 5;
//Replica States
/// <summary> Indicates that the replica is fully functioning and capable of responding
/// to requests.
/// </summary>
public const int Ldap_RS_ON = 0;
/// <summary> Indicates that a new replica has been added but has not received a full
/// download of information from the replica ring.
/// </summary>
public const int Ldap_RS_NEW_REPLICA = 1;
/// <summary> Indicates that the replica is being deleted and that the request has
/// been received.
/// </summary>
public const int Ldap_RS_DYING_REPLICA = 2;
/// <summary> Indicates that the replica is locked. The move operation uses this state
/// to lock the parent naming context of the child naming context that is moving.
/// </summary>
public const int Ldap_RS_LOCKED = 3;
/// <summary> Indicates that a new replica has finished receiving its download from the
/// master replica and is now receiving synchronization updates from other
/// replicas.
/// </summary>
public const int Ldap_RS_TRANSITION_ON = 6;
/// <summary> Indicates that the dying replica needs to synchronize with another replica
/// before being converted either to an external reference, if a root replica,
/// or to a subordinate reference, if a non-root replica.
/// </summary>
public const int Ldap_RS_DEAD_REPLICA = 7;
/// <summary> Indicates that the subordinate references of the new replica are being
/// added.
/// </summary>
public const int Ldap_RS_BEGIN_ADD = 8;
/// <summary> Indicates that a naming context is receiving a new master replica.
///
/// The replica that will be the new master replica is set to this state.
/// </summary>
public const int Ldap_RS_MASTER_START = 11;
/// <summary> Indicates that a naming context has a new master replica.
///
/// When the new master is set to this state, Novell eDirectory knows
/// that the replica is now the master and changes its replica type to
/// master and the old master to read/write.
/// </summary>
public const int Ldap_RS_MASTER_DONE = 12;
/// <summary> Indicates that the naming context is going to split into two naming contexts.
///
/// In this state, other replicas of the naming context are informed of the
/// pending split.
/// </summary>
public const int Ldap_RS_SS_0 = 48; // Replica splitting 0
/// <summary> Indicates that that the split naming context operation has started.
///
/// When the split is finished, the state will change to RS_ON.
/// </summary>
public const int Ldap_RS_SS_1 = 49; // Replica splitting 1
/// <summary> Indicates that that two naming contexts are in the process of joining
/// into one naming context.
///
/// In this state, the replicas that are affected are informed of the join
/// operation. The master replica of the parent and child naming contexts are
/// first set to this state and then all the replicas of the parent and child.
/// New replicas are added where needed.
/// </summary>
public const int Ldap_RS_JS_0 = 64; // Replica joining 0
/// <summary> Indicates that that two naming contexts are in the process of joining
/// into one naming context.
///
/// This state indicates that the join operation is waiting for the new
/// replicas to synchronize and move to the RS_ON state.
/// </summary>
public const int Ldap_RS_JS_1 = 65; // Replica joining 1
/// <summary> Indicates that that two naming contexts are in the process of joining
/// into one naming context.
///
/// This state indicates that all the new replicas are in the RS_ON state
/// and that the rest of the work can be completed.
/// </summary>
public const int Ldap_RS_JS_2 = 66; // Replica joining 2
// Values for flags used in the replica info class structure
/// <summary> Indicates that the replica is involved with a partition operation,
/// for example, merging a tree or moving a subtree.
/// </summary>
public const int Ldap_DS_FLAG_BUSY = 0x0001;
/// <summary> Indicates that this naming context is on the DNS federation boundary.
/// This flag is only set on DNS trees.
/// </summary>
public const int Ldap_DS_FLAG_BOUNDARY = 0x0002;
public NamingContextConstants()
{
}
}
}

View File

@@ -0,0 +1,114 @@
/******************************************************************************
* The MIT License
* Copyright (c) 2003 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.PartitionEntryCountRequest.cs
//
// Author:
// Sunil Kumar (Sunilk@novell.com)
//
// (C) 2003 Novell, Inc (http://www.novell.com)
//
using System;
using Novell.Directory.Ldap;
using Novell.Directory.Ldap.Asn1;
using Novell.Directory.Ldap.Utilclass;
namespace Novell.Directory.Ldap.Extensions
{
/// <summary> Returns a count of the number of entries (objects) in the
/// specified partition.
///
/// To obtain the count of entries, you must create an instance of this
/// class and then call the extendedOperation method with this
/// object as the required LdapExtendedOperation parameter.
///
/// The returned LdapExtendedResponse object can then be converted to
/// a PartitionEntryCountResponse object. This class contains
/// methods for retrieving the returned count.
///
/// The PartitionEntryCountRequest extension uses the following
/// OID:
/// 2.16.840.1.113719.1.27.100.13
///
/// The requestValue has the following format:
///
/// requestValue ::=
/// dn LdapDN
/// </summary>
public class PartitionEntryCountRequest:LdapExtendedOperation
{
static PartitionEntryCountRequest()
{
/*
* Register the extendedresponse class which is returned by the
* server in response to a ListReplicasRequest
*/
try
{
LdapExtendedResponse.register(ReplicationConstants.NAMING_CONTEXT_COUNT_RES, System.Type.GetType("Novell.Directory.Ldap.Extensions.PartitionEntryCountResponse"));
}
catch (System.Exception e)
{
System.Console.Error.WriteLine("Could not register Extended Response -" + " Class not found");
}
}
/// <summary> Constructs an extended operation object for counting entries
/// in a naming context.
///
/// </summary>
/// <param name="dn"> The distinguished name of the partition.
///
/// </param>
/// <exception> LdapException A general exception which includes an
/// error message and an Ldap error code.
/// </exception>
public PartitionEntryCountRequest(System.String dn):base(ReplicationConstants.NAMING_CONTEXT_COUNT_REQ, null)
{
try
{
if (((System.Object) dn == null))
throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
LBEREncoder encoder = new LBEREncoder();
Asn1OctetString asn1_dn = new Asn1OctetString(dn);
asn1_dn.encode(encoder, encodedData);
setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
}
catch (System.IO.IOException ioe)
{
throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More