public override void SyncReplicaFromAllServers(string partition, SyncFromAllServersOptions options) { if (!this.disposed) { if (partition != null) { if (partition.Length != 0) { this.GetADAMHandle(); base.SyncReplicaAllHelper(this.ADAMHandle, this.syncAllFunctionPointer, partition, options, this.SyncFromAllServersCallback, DirectoryContext.ADAMHandle); return; } else { throw new ArgumentException(Res.GetString("EmptyStringParameter"), "partition"); } } else { throw new ArgumentNullException("partition"); } } else { throw new ObjectDisposedException(base.GetType().Name); } }
public override void SyncReplicaFromAllServers(string partition, SyncFromAllServersOptions options) { if (_disposed) { throw new ObjectDisposedException(GetType().Name); } if (partition == null) { throw new ArgumentNullException(nameof(partition)); } if (partition.Length == 0) { throw new ArgumentException(SR.EmptyStringParameter, nameof(partition)); } // get the dsHandle GetADAMHandle(); SyncReplicaAllHelper(_ADAMHandle, _syncAllFunctionPointer, partition, options, SyncFromAllServersCallback, DirectoryContext.ADAMHandle); }
public override void SyncReplicaFromAllServers(string partition, SyncFromAllServersOptions options) { if (_disposed) throw new ObjectDisposedException(GetType().Name); if (partition == null) throw new ArgumentNullException("partition"); if (partition.Length == 0) throw new ArgumentException(Res.GetString(Res.EmptyStringParameter), "partition"); // get the dsHandle GetDSHandle(); SyncReplicaAllHelper(_dsHandle, syncAllFunctionPointer, partition, options, SyncFromAllServersCallback, DirectoryContext.ADHandle); }
public override void SyncReplicaFromAllServers(string partition, SyncFromAllServersOptions options) { }
internal void SyncReplicaAllHelper(IntPtr handle, SyncReplicaFromAllServersCallback syncAllFunctionPointer, string partition, SyncFromAllServersOptions option, SyncUpdateCallback callback, LoadLibrarySafeHandle libHandle) { IntPtr zero = IntPtr.Zero; if (!this.Partitions.Contains(partition)) { throw new ArgumentException(Res.GetString("ServerNotAReplica"), "partition"); } IntPtr procAddress = System.DirectoryServices.ActiveDirectory.UnsafeNativeMethods.GetProcAddress(libHandle, "DsReplicaSyncAllW"); if (procAddress == IntPtr.Zero) { throw ExceptionHelper.GetExceptionFromErrorCode(Marshal.GetLastWin32Error()); } System.DirectoryServices.ActiveDirectory.UnsafeNativeMethods.DsReplicaSyncAllW delegateForFunctionPointer = (System.DirectoryServices.ActiveDirectory.UnsafeNativeMethods.DsReplicaSyncAllW)Marshal.GetDelegateForFunctionPointer(procAddress, typeof(System.DirectoryServices.ActiveDirectory.UnsafeNativeMethods.DsReplicaSyncAllW)); int errorCode = delegateForFunctionPointer(handle, partition, ((int)option) | 4, syncAllFunctionPointer, IntPtr.Zero, ref zero); try { if (zero != IntPtr.Zero) { SyncFromAllServersOperationException exception = ExceptionHelper.CreateSyncAllException(zero, false); if (exception != null) { throw exception; } } else if (errorCode != 0) { throw new SyncFromAllServersOperationException(ExceptionHelper.GetErrorMessage(errorCode, false)); } } finally { if (zero != IntPtr.Zero) { System.DirectoryServices.ActiveDirectory.UnsafeNativeMethods.LocalFree(zero); } } }
public abstract virtual void SyncReplicaFromAllServers(string partition, SyncFromAllServersOptions options) {}
public override void SyncReplicaFromAllServers(string partition, SyncFromAllServersOptions options) { throw new NotImplementedException(); }
public virtual void SyncReplicaFromAllServers(string partition, SyncFromAllServersOptions options) { }
internal void SyncReplicaAllHelper(IntPtr handle, SyncReplicaFromAllServersCallback syncAllFunctionPointer, string partition, SyncFromAllServersOptions option, SyncUpdateCallback callback, LoadLibrarySafeHandle libHandle) { IntPtr errorInfo = (IntPtr)0; if (!Partitions.Contains(partition)) throw new ArgumentException(Res.GetString(Res.ServerNotAReplica), "partition"); // we want to return the dn instead of DNS guid // call DsReplicaSyncAllW IntPtr functionPtr = UnsafeNativeMethods.GetProcAddress(libHandle, "DsReplicaSyncAllW"); if (functionPtr == (IntPtr)0) { throw ExceptionHelper.GetExceptionFromErrorCode(Marshal.GetLastWin32Error()); } UnsafeNativeMethods.DsReplicaSyncAllW dsReplicaSyncAllW = (UnsafeNativeMethods.DsReplicaSyncAllW)Marshal.GetDelegateForFunctionPointer(functionPtr, typeof(UnsafeNativeMethods.DsReplicaSyncAllW)); int result = dsReplicaSyncAllW(handle, partition, (int)option | DS_REPSYNCALL_ID_SERVERS_BY_DN, syncAllFunctionPointer, (IntPtr)0, ref errorInfo); try { // error happens during the synchronization if (errorInfo != (IntPtr)0) { SyncFromAllServersOperationException e = ExceptionHelper.CreateSyncAllException(errorInfo, false); if (e == null) return; else throw e; } else { // API does not return error infor occurred during synchronization, but result is not success. if (result != 0) throw new SyncFromAllServersOperationException(ExceptionHelper.GetErrorMessage(result, false)); } } finally { // release the memory if (errorInfo != (IntPtr)0) UnsafeNativeMethods.LocalFree(errorInfo); } }
internal void SyncReplicaAllHelper(IntPtr handle, SyncReplicaFromAllServersCallback syncAllFunctionPointer, string partition, SyncFromAllServersOptions option, SyncUpdateCallback callback, LoadLibrarySafeHandle libHandle) { IntPtr intPtr = (IntPtr)0; if (this.Partitions.Contains(partition)) { IntPtr procAddress = UnsafeNativeMethods.GetProcAddress(libHandle, "DsReplicaSyncAllW"); if (procAddress != (IntPtr)0) { UnsafeNativeMethods.DsReplicaSyncAllW delegateForFunctionPointer = (UnsafeNativeMethods.DsReplicaSyncAllW)Marshal.GetDelegateForFunctionPointer(procAddress, typeof(UnsafeNativeMethods.DsReplicaSyncAllW)); int num = delegateForFunctionPointer(handle, partition, (int)option | 4, syncAllFunctionPointer, (IntPtr)0, ref intPtr); try { if (intPtr == (IntPtr)0) { if (num != 0) { throw new SyncFromAllServersOperationException(ExceptionHelper.GetErrorMessage(num, false)); } } else { SyncFromAllServersOperationException syncFromAllServersOperationException = ExceptionHelper.CreateSyncAllException(intPtr, false); if (syncFromAllServersOperationException != null) { throw syncFromAllServersOperationException; } } } finally { if (intPtr != (IntPtr)0) { UnsafeNativeMethods.LocalFree(intPtr); } } return; } else { throw ExceptionHelper.GetExceptionFromErrorCode(Marshal.GetLastWin32Error()); } } else { throw new ArgumentException(Res.GetString("ServerNotAReplica"), "partition"); } }
internal unsafe void SyncReplicaAllHelper(IntPtr handle, SyncReplicaFromAllServersCallback syncAllCallback, string partition, SyncFromAllServersOptions option, SyncUpdateCallback?callback, SafeLibraryHandle libHandle) { IntPtr errorInfo = (IntPtr)0; if (!Partitions.Contains(partition)) { throw new ArgumentException(SR.ServerNotAReplica, nameof(partition)); } // we want to return the dn instead of DNS guid // call DsReplicaSyncAllW var dsReplicaSyncAllW = (delegate * unmanaged <IntPtr, char *, int, IntPtr, IntPtr, IntPtr *, int>)global::Interop.Kernel32.GetProcAddress(libHandle, "DsReplicaSyncAllW"); if (dsReplicaSyncAllW == null) { throw ExceptionHelper.GetExceptionFromErrorCode(Marshal.GetLastWin32Error()); } int result; fixed(char *partitionPtr = partition) { IntPtr syncAllFunctionPointer = Marshal.GetFunctionPointerForDelegate(syncAllCallback); result = dsReplicaSyncAllW(handle, partitionPtr, (int)option | DS_REPSYNCALL_ID_SERVERS_BY_DN, syncAllFunctionPointer, (IntPtr)0, &errorInfo); GC.KeepAlive(syncAllCallback); } try { // error happens during the synchronization if (errorInfo != (IntPtr)0) { SyncFromAllServersOperationException?e = ExceptionHelper.CreateSyncAllException(errorInfo, false); if (e == null) { return; } else { throw e; } } else { // API does not return error infor occurred during synchronization, but result is not success. if (result != 0) { throw new SyncFromAllServersOperationException(ExceptionHelper.GetErrorMessage(result, false)); } } } finally { // release the memory if (errorInfo != (IntPtr)0) { global::Interop.Kernel32.LocalFree(errorInfo); } } }
public abstract void SyncReplicaFromAllServers(string partition, SyncFromAllServersOptions options);
internal void SyncReplicaAllHelper(IntPtr handle, SyncReplicaFromAllServersCallback syncAllFunctionPointer, string partition, SyncFromAllServersOptions option, SyncUpdateCallback callback, LoadLibrarySafeHandle libHandle) { IntPtr errorInfo = (IntPtr)0; if (!Partitions.Contains(partition)) { throw new ArgumentException(SR.ServerNotAReplica, "partition"); } // we want to return the dn instead of DNS guid // call DsReplicaSyncAllW IntPtr functionPtr = UnsafeNativeMethods.GetProcAddress(libHandle, "DsReplicaSyncAllW"); if (functionPtr == (IntPtr)0) { throw ExceptionHelper.GetExceptionFromErrorCode(Marshal.GetLastWin32Error()); } UnsafeNativeMethods.DsReplicaSyncAllW dsReplicaSyncAllW = (UnsafeNativeMethods.DsReplicaSyncAllW)Marshal.GetDelegateForFunctionPointer(functionPtr, typeof(UnsafeNativeMethods.DsReplicaSyncAllW)); int result = dsReplicaSyncAllW(handle, partition, (int)option | DS_REPSYNCALL_ID_SERVERS_BY_DN, syncAllFunctionPointer, (IntPtr)0, ref errorInfo); try { // error happens during the synchronization if (errorInfo != (IntPtr)0) { SyncFromAllServersOperationException e = ExceptionHelper.CreateSyncAllException(errorInfo, false); if (e == null) { return; } else { throw e; } } else { // API does not return error infor occurred during synchronization, but result is not success. if (result != 0) { throw new SyncFromAllServersOperationException(ExceptionHelper.GetErrorMessage(result, false)); } } } finally { // release the memory if (errorInfo != (IntPtr)0) { UnsafeNativeMethods.LocalFree(errorInfo); } } }
internal void SyncReplicaAllHelper(IntPtr handle, SyncReplicaFromAllServersCallback syncAllFunctionPointer, string partition, SyncFromAllServersOptions option, SyncUpdateCallback callback, LoadLibrarySafeHandle libHandle) { IntPtr zero = IntPtr.Zero; if (!this.Partitions.Contains(partition)) { throw new ArgumentException(Res.GetString("ServerNotAReplica"), "partition"); } IntPtr procAddress = System.DirectoryServices.ActiveDirectory.UnsafeNativeMethods.GetProcAddress(libHandle, "DsReplicaSyncAllW"); if (procAddress == IntPtr.Zero) { throw ExceptionHelper.GetExceptionFromErrorCode(Marshal.GetLastWin32Error()); } System.DirectoryServices.ActiveDirectory.UnsafeNativeMethods.DsReplicaSyncAllW delegateForFunctionPointer = (System.DirectoryServices.ActiveDirectory.UnsafeNativeMethods.DsReplicaSyncAllW) Marshal.GetDelegateForFunctionPointer(procAddress, typeof(System.DirectoryServices.ActiveDirectory.UnsafeNativeMethods.DsReplicaSyncAllW)); int errorCode = delegateForFunctionPointer(handle, partition, ((int) option) | 4, syncAllFunctionPointer, IntPtr.Zero, ref zero); try { if (zero != IntPtr.Zero) { SyncFromAllServersOperationException exception = ExceptionHelper.CreateSyncAllException(zero, false); if (exception != null) { throw exception; } } else if (errorCode != 0) { throw new SyncFromAllServersOperationException(ExceptionHelper.GetErrorMessage(errorCode, false)); } } finally { if (zero != IntPtr.Zero) { System.DirectoryServices.ActiveDirectory.UnsafeNativeMethods.LocalFree(zero); } } }