D
Dan
Hi
I need to get the Domain Name in NT format. I can do it with the
following code, but it takes 5 seconds to execute, which is to much for
me. Anyone know how to do it faster ?
Thanks
Dany
DirectoryEntry rootDSE = new
DirectoryEntry("LDAP://RootDSE");
string dnc =
(string)rootDSE.Properties["defaultNamingContext"].Value;
DWORD rc; //code de retour
HANDLE handle = IntPtr.Zero;
rc = NativeMethods.DsBind(
null,
null,
out handle
);
if (rc != 0)
{
throw new Exception("...");
}
string[] nomDomaine;
try
{
nomDomaine = NameUtility.DsCrackNamesWrapper(
new string[] { dnc },
handle,
DS_NAME_FORMAT.DS_FQDN_1779_NAME,
DS_NAME_FORMAT.DS_NT4_ACCOUNT_NAME
);
}
catch (Exception ex)
{
throw new Exception("...." + ex.Message);
}
finally
{
NativeMethods.DsUnBind(ref handle);
}
return nomDomaine[0];
I need to get the Domain Name in NT format. I can do it with the
following code, but it takes 5 seconds to execute, which is to much for
me. Anyone know how to do it faster ?
Thanks
Dany
DirectoryEntry rootDSE = new
DirectoryEntry("LDAP://RootDSE");
string dnc =
(string)rootDSE.Properties["defaultNamingContext"].Value;
DWORD rc; //code de retour
HANDLE handle = IntPtr.Zero;
rc = NativeMethods.DsBind(
null,
null,
out handle
);
if (rc != 0)
{
throw new Exception("...");
}
string[] nomDomaine;
try
{
nomDomaine = NameUtility.DsCrackNamesWrapper(
new string[] { dnc },
handle,
DS_NAME_FORMAT.DS_FQDN_1779_NAME,
DS_NAME_FORMAT.DS_NT4_ACCOUNT_NAME
);
}
catch (Exception ex)
{
throw new Exception("...." + ex.Message);
}
finally
{
NativeMethods.DsUnBind(ref handle);
}
return nomDomaine[0];