Beispiel #1
0
 private IReadOnlyList <DirectoryServiceNameResult> GetNameResults(IntPtr ptr)
 {
     try
     {
         var results = ptr.ReadStruct <DS_NAME_RESULTW>();
         return(results.rItems.ReadArray <DS_NAME_RESULT_ITEMW>(results.cItems)
                .Select(DirectoryServiceNameResult.Create).ToList().AsReadOnly());
     }
     finally
     {
         DirectoryServiceNativeMethods.DsFreeNameResult(ptr);
     }
 }
Beispiel #2
0
 /// <summary>
 /// Crack one or more names on the domain controller.
 /// </summary>
 /// <param name="flags">Flags for the cracking.</param>
 /// <param name="format_offered">Format of the names.</param>
 /// <param name="format_desired">Desired format of the names.</param>
 /// <param name="names">The list of names to crack.</param>
 /// <param name="throw_on_error">True to throw on error.</param>
 /// <returns>The cracked names.</returns>
 public NtResult <IReadOnlyList <DirectoryServiceNameResult> > CrackNames(
     DirectoryServiceNameFlags flags,
     DirectoryServiceNameFormat format_offered,
     DirectoryServiceNameFormat format_desired,
     IEnumerable <string> names,
     bool throw_on_error)
 {
     string[] names_arr = names.ToArray();
     if (names_arr.Length == 0)
     {
         return(new List <DirectoryServiceNameResult>().AsReadOnly().CreateResult <IReadOnlyList <DirectoryServiceNameResult> >());
     }
     return(DirectoryServiceNativeMethods.DsCrackNames(_handle, flags, format_offered,
                                                       format_desired, names_arr.Length, names_arr, out IntPtr results).CreateWin32Result(throw_on_error,
                                                                                                                                          () => GetNameResults(results)));
 }
Beispiel #3
0
        protected override bool ReleaseHandle()
        {
            IntPtr h = handle;

            return(DirectoryServiceNativeMethods.DsUnBind(ref h) == Win32Error.SUCCESS);
        }
Beispiel #4
0
 /// <summary>
 /// Bind to a directory service.
 /// </summary>
 /// <param name="domain_controller_name">The name of the domain controller. Can be null.</param>
 /// <param name="dns_domain_name">The DNS domain name.</param>
 /// <param name="throw_on_error">True to throw on error.</param>
 /// <returns>The directory service binding.</returns>
 public static NtResult <DirectoryServiceBinding> Bind(string domain_controller_name, string dns_domain_name, bool throw_on_error)
 {
     return(DirectoryServiceNativeMethods.DsBind(domain_controller_name, dns_domain_name,
                                                 out SafeDirectoryServiceHandle handle).CreateWin32Result(throw_on_error, () => new DirectoryServiceBinding(handle)));
 }