From 6093bba4f87b4435bec03f2efb8338c6b6142658 Mon Sep 17 00:00:00 2001 From: Zac Bergquist Date: Fri, 15 Aug 2025 18:54:00 -0600 Subject: [PATCH] Import the host description when discovering desktops Include the decription attribute in LDAP queries, and set the resulting description as the metdata description on any Teleport desktop resources we create. This is not surfaced anywhere in the UI (though that would be a nice addition in the future). Updates #55148 --- lib/srv/desktop/discovery.go | 8 ++++++++ lib/srv/desktop/windows_server.go | 1 + 2 files changed, 9 insertions(+) diff --git a/lib/srv/desktop/discovery.go b/lib/srv/desktop/discovery.go index ab9be9b7a18f7..219d05d7ae24d 100644 --- a/lib/srv/desktop/discovery.go +++ b/lib/srv/desktop/discovery.go @@ -44,6 +44,10 @@ const ( // attrName is the name of an LDAP object. attrName = "name" + // description is a description of an LDAP object. + attrDescription = "description" + attrDescriptionMaxLength = 1024 // https://learn.microsoft.com/en-us/windows/win32/adschema/a-description + // attrCommonName is the common name of an LDAP object, or "CN". attrCommonName = "cn" @@ -366,5 +370,9 @@ func (s *WindowsService) ldapEntryToWindowsDesktop( // purge them if they stop being detected, and discovery of large Windows fleets can // take a long time. desktop.SetExpiry(s.cfg.Clock.Now().UTC().Add(apidefaults.ServerAnnounceTTL * 3)) + + description := entry.GetAttributeValue(attrDescription) + desktop.Metadata.Description = description[:min(len(description), attrDescriptionMaxLength)] + return desktop, nil } diff --git a/lib/srv/desktop/windows_server.go b/lib/srv/desktop/windows_server.go index cb9e43f5eed59..2194f83dc7617 100644 --- a/lib/srv/desktop/windows_server.go +++ b/lib/srv/desktop/windows_server.go @@ -104,6 +104,7 @@ const ( // see: https://docs.microsoft.com/en-us/windows/win32/adschema/c-computer#windows-server-2012-attributes var computerAttributes = []string{ attrName, + attrDescription, attrCommonName, attrDistinguishedName, attrDNSHostName,