File tree Expand file tree Collapse file tree
rust/user-info-fetcher/src/backend Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ const LDAP_FIELD_OBJECT_DISTINGUISHED_NAME: &str = "dn";
8989const LDAP_FIELD_USER_NAME : & str = "userPrincipalName" ;
9090const LDAP_FIELD_USER_PRIMARY_GROUP_RID : & str = "primaryGroupID" ;
9191const LDAP_FIELD_GROUP_MEMBER : & str = "member" ;
92+ const LDAP_FIELD_SAM_ACCOUNT_NAME : & str = "sAMAccountName" ;
9293
9394#[ tracing:: instrument( skip(
9495 tls,
@@ -133,9 +134,7 @@ pub(crate) async fn get_user_info(
133134 )
134135 )
135136 }
136- UserInfoRequest :: UserInfoRequestByName ( username) => {
137- format ! ( "{LDAP_FIELD_USER_NAME}={}" , ldap_escape( & username. username) )
138- }
137+ UserInfoRequest :: UserInfoRequestByName ( username) => user_name_filter ( & username. username ) ,
139138 } ;
140139 let requested_user_attrs = [
141140 LDAP_FIELD_OBJECT_SECURITY_ID ,
@@ -179,6 +178,16 @@ pub(crate) async fn get_user_info(
179178 . await
180179}
181180
181+ /// Constructs a user filter that searches both the UPN as well as the sAMAccountName attributes.
182+ /// See this issue for details: https://github.com/stackabletech/opa-operator/issues/702
183+ fn user_name_filter ( username : & str ) -> String {
184+ let escaped_username = ldap_escape ( username) ;
185+ let realm = "SBLE.TEST" ; // TODO: Replace with actual realm
186+ format ! (
187+ "(|({LDAP_FIELD_USER_NAME}={escaped_username}@{realm})({LDAP_FIELD_USER_NAME}={escaped_username})({LDAP_FIELD_SAM_ACCOUNT_NAME}={escaped_username}))"
188+ )
189+ }
190+
182191#[ tracing:: instrument(
183192 skip(
184193 ldap,
You can’t perform that action at this time.
0 commit comments