private static async Task <ModifyDNResponse> SendModifyDnRequestAsync(LdapConnection connection, string dn, string parentDn, string newName, bool?deleteOldRDN, DirectoryControl[] controls,
                                                                              ILinqToLdapLogger log = null, PartialResultProcessing resultProcessing = LdapConfiguration.DefaultAsyncResultProcessing)
        {
            var request = new ModifyDNRequest
            {
                DistinguishedName          = dn,
                NewParentDistinguishedName = parentDn,
                NewName = newName,
            };

            if (deleteOldRDN.HasValue)
            {
                request.DeleteOldRdn = deleteOldRDN.Value;
            }
            if (controls != null)
            {
                request.Controls.AddRange(controls);
            }
            if (log != null && log.TraceEnabled)
            {
                log.Trace(request.ToLogString());
            }

#if NET45
            return(await Task.Factory.FromAsync(
                       (callback, state) =>
            {
                return connection.BeginSendRequest(request, resultProcessing, callback, state);
            },
                       (asyncresult) =>
            {
                return connection.EndSendRequest(asyncresult) as ModifyDNResponse;
            },
                       null
                       ).ConfigureAwait(false));
#else
            return(await Task.Run(() => connection.SendRequest(request) as ModifyDNResponse).ConfigureAwait(false));
#endif
        }
Exemplo n.º 2
0
        private static ModifyDNResponse SendModifyDnRequest(LdapConnection connection, string dn, string parentDn, string newName, bool?deleteOldRDN, DirectoryControl[] controls, ILinqToLdapLogger log = null)
        {
            var request = new ModifyDNRequest
            {
                DistinguishedName          = dn,
                NewParentDistinguishedName = parentDn,
                NewName = newName,
            };

            if (deleteOldRDN.HasValue)
            {
                request.DeleteOldRdn = deleteOldRDN.Value;
            }
            if (controls != null)
            {
                request.Controls.AddRange(controls);
            }
            if (log != null && log.TraceEnabled)
            {
                log.Trace(request.ToLogString());
            }

            return(connection.SendRequest(request) as ModifyDNResponse);
        }