Skip to content

Commit c08d4f3

Browse files
committed
[Unattended answer file] Get domain name using Active Directory API
1 parent 62a4ba9 commit c08d4f3

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

DISMTools.vbproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
<Reference Include="System.Design">
129129
<Private>True</Private>
130130
</Reference>
131+
<Reference Include="System.DirectoryServices" />
131132
<Reference Include="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
132133
<Private>True</Private>
133134
</Reference>

Elements/AutoUnattend/ActiveDirectory/DomainServicesModule.vb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Imports System.Runtime.InteropServices
2+
Imports System.DirectoryServices.ActiveDirectory.Domain
23

34
Module DomainServicesModule
45

@@ -84,7 +85,7 @@ Module DomainServicesModule
8485
Dim domain As IntPtr = GetDomainNameInformation()
8586
If domain <> IntPtr.Zero Then
8687
DynaLog.LogMessage("GetDomainNameInformation did not return bogus data. Parsing...")
87-
domainName = Marshal.PtrToStringAuto(domain)
88+
domainName = GetComputerDomain().Name ' Get it from AD DS .NET API
8889
End If
8990
End If
9091
DynaLog.LogMessage("Domain name: " & ControlChars.Quote & domainName & ControlChars.Quote & ". If it's empty, it could be because the device is not part of a domain.")

0 commit comments

Comments
 (0)