@@ -12,8 +12,10 @@ internal SchemaMap(string? server = null)
1212 {
1313 string path = server is null ? "LDAP://RootDSE" : $ "LDAP://{ server } /RootDSE";
1414 using DirectoryEntry root = new ( path ) ;
15- string ? ctx = root . Properties [ "schemaNamingContext" ] [ 0 ] ? . ToString ( ) ;
16- if ( ctx is not null ) PopulateMap ( ctx , _schemaMap ) ;
15+ string ? ctxSchema = root . Properties [ "schemaNamingContext" ] [ 0 ] ? . ToString ( ) ;
16+ string ? ctxConfig = root . Properties [ "configurationNamingContext" ] [ 0 ] ? . ToString ( ) ;
17+ if ( ctxSchema is not null ) PopulateSchema ( ctxSchema , _schemaMap ) ;
18+ if ( ctxConfig is not null ) PopulateExtendedRights ( ctxConfig , _schemaMap ) ;
1719 }
1820
1921 internal string Translate ( Guid guid , string defaultValue )
@@ -26,20 +28,44 @@ internal string Translate(Guid guid, string defaultValue)
2628 return guid . ToString ( ) ;
2729 }
2830
29- private static void PopulateMap (
31+ private static void PopulateSchema (
3032 string schemaNamingContext ,
3133 Dictionary < Guid , string > map )
3234 {
3335 using DirectoryEntry root = new ( $ "LDAP://{ schemaNamingContext } ") ;
3436 using DirectorySearcher searcher = new (
3537 searchRoot : root ,
36- filter : "(schemaIDGUID=*)" ,
37- propertiesToLoad : [ "cn" , "schemaIDGuid" ] ) ;
38+ filter : "(&(schemaIdGuid=*)(|(objectClass=attributeSchema)(objectClass=classSchema)))" ,
39+ propertiesToLoad : [ "cn" , "schemaIdGuid" ] )
40+ {
41+ PageSize = 1000
42+ } ;
43+
44+ foreach ( SearchResult result in searcher . FindAll ( ) )
45+ {
46+ map . TryAdd (
47+ new Guid ( ( byte [ ] ) result . Properties [ "schemaIdGuid" ] [ 0 ] ) ,
48+ result . Properties [ "cn" ] [ 0 ] . ToString ( ) ) ;
49+ }
50+ }
51+
52+ private static void PopulateExtendedRights (
53+ string configurationNamingContext ,
54+ Dictionary < Guid , string > map )
55+ {
56+ using DirectoryEntry root = new ( $ "LDAP://CN=Extended-Rights,{ configurationNamingContext } ") ;
57+ using DirectorySearcher searcher = new (
58+ searchRoot : root ,
59+ filter : "(objectClass=controlAccessRight)" ,
60+ propertiesToLoad : [ "cn" , "rightsGuid" ] )
61+ {
62+ PageSize = 1000
63+ } ;
3864
3965 foreach ( SearchResult result in searcher . FindAll ( ) )
4066 {
41- map . Add (
42- new Guid ( ( byte [ ] ) result . Properties [ "schemaIDGUID " ] [ 0 ] ) ,
67+ map . TryAdd (
68+ Guid . Parse ( result . Properties [ "rightsGuid " ] [ 0 ] . ToString ( ) ) ,
4369 result . Properties [ "cn" ] [ 0 ] . ToString ( ) ) ;
4470 }
4571 }
0 commit comments