Exemplo n.º 1
0
        private StoreCtx CreateContextFromDirectoryEntry(DirectoryEntry entry)
        {
            StoreCtx storeCtx;

            Debug.Assert(entry != null);

            GlobalDebug.WriteLineIf(GlobalDebug.Info, "PrincipalContext", "CreateContextFromDirectoryEntry: path is " + entry.Path);

            if (entry.Path.StartsWith("LDAP:", StringComparison.Ordinal))
            {
                if (this.ContextType == ContextType.ApplicationDirectory)
                {
                    storeCtx = new ADAMStoreCtx(entry, true, _username, _password, _name, _options);
                }
                else
                {
                    storeCtx = new ADStoreCtx(entry, true, _username, _password, _options);
                }
            }
            else
            {
                Debug.Assert(entry.Path.StartsWith("WinNT:", StringComparison.Ordinal));
                storeCtx = new SAMStoreCtx(entry, true, _username, _password, _options);
            }

            storeCtx.OwningContext = this;
            return(storeCtx);
        }
Exemplo n.º 2
0
        internal ADEntriesSet(SearchResultCollection src, ADStoreCtx storeCtx)
        {
            GlobalDebug.WriteLineIf(GlobalDebug.Info, "ADEntriesSet", "Ctor");

            _searchResults = src;
            _storeCtx = storeCtx;
            _enumerator = src.GetEnumerator();
        }
Exemplo n.º 3
0
        internal ADEntriesSet(SearchResultCollection src, ADStoreCtx storeCtx)
        {
            GlobalDebug.WriteLineIf(GlobalDebug.Info, "ADEntriesSet", "Ctor");

            _searchResults = src;
            _storeCtx      = storeCtx;
            _enumerator    = src.GetEnumerator();
        }
Exemplo n.º 4
0
        internal override void RestoreBookmark(ResultSetBookmark bookmark)
        {
            ADDNLinkedAttrSetBookmark aDDNLinkedAttrSetBookmark = (ADDNLinkedAttrSetBookmark)bookmark;

            this.usersVisited               = aDDNLinkedAttrSetBookmark.usersVisited;
            this.groupsToVisit              = aDDNLinkedAttrSetBookmark.groupsToVisit;
            this.groupsVisited              = aDDNLinkedAttrSetBookmark.groupsVisited;
            this.storeCtx                   = aDDNLinkedAttrSetBookmark.storeCtx;
            this.current                    = aDDNLinkedAttrSetBookmark.current;
            this.returnedPrimaryGroup       = aDDNLinkedAttrSetBookmark.returnedPrimaryGroup;
            this.foreignMembersCurrentGroup = aDDNLinkedAttrSetBookmark.foreignMembersCurrentGroup;
            this.fakePrincipalMembers       = aDDNLinkedAttrSetBookmark.fakePrincipalMembers;
            this.foreignMembersToReturn     = aDDNLinkedAttrSetBookmark.foreignMembersToReturn;
            this.currentForeignPrincipal    = aDDNLinkedAttrSetBookmark.currentForeignPrincipal;
            this.currentForeignDE           = aDDNLinkedAttrSetBookmark.currentForeignDE;
            this.foreignGroups              = aDDNLinkedAttrSetBookmark.foreignGroups;
            if (this.queryMembersResults != null)
            {
                this.queryMembersResults.Dispose();
            }
            this.queryMembersResults           = aDDNLinkedAttrSetBookmark.queryMembersResults;
            this.queryMembersResultEnumerator  = aDDNLinkedAttrSetBookmark.queryMembersResultEnumerator;
            this.memberSearchResults           = aDDNLinkedAttrSetBookmark.memberSearchResults;
            this.memberSearchResultsEnumerator = aDDNLinkedAttrSetBookmark.memberSearchResultsEnumerator;
            this.atBeginning   = aDDNLinkedAttrSetBookmark.atBeginning;
            this.expansionMode = aDDNLinkedAttrSetBookmark.expansionMode;
            this.members       = aDDNLinkedAttrSetBookmark.members;
            this.membersEnum   = aDDNLinkedAttrSetBookmark.membersEnum;
            if (this.membersQueue != null)
            {
                this.membersQueue.Clear();
                if (aDDNLinkedAttrSetBookmark.membersQueue != null)
                {
                    foreach (IEnumerable enumerable in aDDNLinkedAttrSetBookmark.membersQueue)
                    {
                        this.membersQueue.Enqueue(enumerable);
                    }
                }
            }
            if (this.memberSearchersQueue != null)
            {
                foreach (DirectorySearcher directorySearcher in this.memberSearchersQueue)
                {
                    directorySearcher.Dispose();
                }
                this.memberSearchersQueue.Clear();
                if (aDDNLinkedAttrSetBookmark.memberSearcherQueue != null)
                {
                    foreach (DirectorySearcher directorySearcher1 in aDDNLinkedAttrSetBookmark.memberSearcherQueue)
                    {
                        this.memberSearchersQueue.Enqueue(directorySearcher1);
                    }
                }
            }
        }
Exemplo n.º 5
0
        private bool ExpandForeignGroupEnumerator()
        {
            GroupPrincipal item = this.foreignGroups[0];

            this.foreignGroups.RemoveAt(0);
            this.storeCtx = (ADStoreCtx)item.Context.QueryCtx;
            this.membersQueue.Enqueue(new RangeRetriever((DirectoryEntry)item.UnderlyingObject, "member", true));
            string value = (string)((DirectoryEntry)item.UnderlyingObject).Properties["distinguishedName"].Value;

            this.groupsVisited.Add(value);
            return(true);
        }
Exemplo n.º 6
0
        internal TokenGroupSet(
                             string userDN,
                             ADStoreCtx storeCtx,
                             bool readDomainGroups)
        {
            _principalDN = userDN;
            _storeCtx = storeCtx;
            _attributeToQuery = readDomainGroups ? "tokenGroups" : "tokenGroupsGlobalAndUniversal";

            GlobalDebug.WriteLineIf(GlobalDebug.Info,
                                    "TokenGroupSet",
                                    "TokenGroupSet: userDN={0}",
                                    userDN);
        }
Exemplo n.º 7
0
        internal TokenGroupSet(
            string userDN,
            ADStoreCtx storeCtx,
            bool readDomainGroups)
        {
            _principalDN      = userDN;
            _storeCtx         = storeCtx;
            _attributeToQuery = readDomainGroups ? "tokenGroups" : "tokenGroupsGlobalAndUniversal";

            GlobalDebug.WriteLineIf(GlobalDebug.Info,
                                    "TokenGroupSet",
                                    "TokenGroupSet: userDN={0}",
                                    userDN);
        }
Exemplo n.º 8
0
        internal ADDNConstraintLinkedAttrSet(
                            ConstraintType constraint,
                            object constraintData,
                            string groupDN,
                            IEnumerable[] members,
                            string primaryGroupDN,
                            DirectorySearcher queryMembersSearcher,
                            bool recursive,
                            ADStoreCtx storeCtx) : base(groupDN, members, primaryGroupDN, queryMembersSearcher, recursive, storeCtx)
        {
            Debug.Assert(constraintData != null);

            _constraint = constraint;
            _constraintData = constraintData;
        }
Exemplo n.º 9
0
        internal ADDNConstraintLinkedAttrSet(
            ConstraintType constraint,
            object constraintData,
            string groupDN,
            IEnumerable[] members,
            string primaryGroupDN,
            DirectorySearcher queryMembersSearcher,
            bool recursive,
            ADStoreCtx storeCtx) : base(groupDN, members, primaryGroupDN, queryMembersSearcher, recursive, storeCtx)
        {
            Debug.Assert(constraintData != null);

            _constraint     = constraint;
            _constraintData = constraintData;
        }
Exemplo n.º 10
0
 static internal Principal DirectoryEntryAsPrincipal(DirectoryEntry de, ADStoreCtx storeCtx)
 {
     if (ADUtils.IsOfObjectClass(de, "computer") ||
         ADUtils.IsOfObjectClass(de, "user") ||
         ADUtils.IsOfObjectClass(de, "group"))
     {
         return(storeCtx.GetAsPrincipal(de, null));
     }
     else if (ADUtils.IsOfObjectClass(de, "foreignSecurityPrincipal"))
     {
         return(storeCtx.ResolveCrossStoreRefToPrincipal(de));
     }
     else
     {
         return(storeCtx.GetAsPrincipal(de, null));
     }
 }
Exemplo n.º 11
0
 static internal Principal SearchResultAsPrincipal(SearchResult sr, ADStoreCtx storeCtx, object discriminant)
 {
     if (ADUtils.IsOfObjectClass(sr, "computer") ||
         ADUtils.IsOfObjectClass(sr, "user") ||
         ADUtils.IsOfObjectClass(sr, "group"))
     {
         return(storeCtx.GetAsPrincipal(sr, discriminant));
     }
     else if (ADUtils.IsOfObjectClass(sr, "foreignSecurityPrincipal"))
     {
         return(storeCtx.ResolveCrossStoreRefToPrincipal(sr.GetDirectoryEntry()));
     }
     else
     {
         return(storeCtx.GetAsPrincipal(sr, discriminant));
     }
 }
Exemplo n.º 12
0
		internal TokenGroupSet(string userDN, ADStoreCtx storeCtx, bool readDomainGroups)
		{
			string str;
			this.atBeginning = true;
			this.principalDN = userDN;
			this.storeCtx = storeCtx;
			TokenGroupSet tokenGroupSet = this;
			if (readDomainGroups)
			{
				str = "tokenGroups";
			}
			else
			{
				str = "tokenGroupsGlobalAndUniversal";
			}
			tokenGroupSet.attributeToQuery = str;
		}
Exemplo n.º 13
0
		internal static Principal DirectoryEntryAsPrincipal(DirectoryEntry de, ADStoreCtx storeCtx)
		{
			if (ADUtils.IsOfObjectClass(de, "computer") || ADUtils.IsOfObjectClass(de, "user") || ADUtils.IsOfObjectClass(de, "group"))
			{
				return storeCtx.GetAsPrincipal(de, null);
			}
			else
			{
				if (!ADUtils.IsOfObjectClass(de, "foreignSecurityPrincipal"))
				{
					return storeCtx.GetAsPrincipal(de, null);
				}
				else
				{
					return storeCtx.ResolveCrossStoreRefToPrincipal(de);
				}
			}
		}
Exemplo n.º 14
0
        private bool ExpandForeignGroupSearcher()
        {
            GroupPrincipal item = this.foreignGroups[0];

            this.foreignGroups.RemoveAt(0);
            this.storeCtx = (ADStoreCtx)item.Context.QueryCtx;
            DirectorySearcher directorySearcher = SDSUtils.ConstructSearcher((DirectoryEntry)item.UnderlyingObject);

            directorySearcher.Filter              = "(objectClass=*)";
            directorySearcher.SearchScope         = SearchScope.Base;
            directorySearcher.AttributeScopeQuery = "member";
            directorySearcher.CacheResults        = false;
            this.memberSearchersQueue.Enqueue(directorySearcher);
            string value = (string)((DirectoryEntry)item.UnderlyingObject).Properties["distinguishedName"].Value;

            this.groupsVisited.Add(value);
            return(true);
        }
Exemplo n.º 15
0
        internal TokenGroupSet(string userDN, ADStoreCtx storeCtx, bool readDomainGroups)
        {
            string str;

            this.atBeginning = true;
            this.principalDN = userDN;
            this.storeCtx    = storeCtx;
            TokenGroupSet tokenGroupSet = this;

            if (readDomainGroups)
            {
                str = "tokenGroups";
            }
            else
            {
                str = "tokenGroupsGlobalAndUniversal";
            }
            tokenGroupSet.attributeToQuery = str;
        }
Exemplo n.º 16
0
        // This class can be used to either enumerate the members of a group, or the groups
        // to which a principal belongs.  If being used to enumerate the members of a group:
        //      * groupDN --- the DN of the group we're enumerating
        //      * members --- array of enumerators containing the DNs of the members of the group we're enumerating (the "member" attribute)
        //      * primaryGroupDN --- should be null
        //      * recursive --- whether or not to recursively enumerate group membership
        //
        // If being used to enumerate the groups to which a principal belongs:
        //      * groupDN --- the DN of the principal (i.e., the user)
        //      * members --- the DNs of the groups to which that principal belongs (e.g, the "memberOf" attribute)
        //      * primaryGroupDN --- the DN of the principal's primary group (constructed from the "primaryGroupID" attribute)
        //      * recursive --- should be false
        //
        // Note that the variables in this class are generally named in accord with the "enumerating the members
        // of a group" case.
        //
        // It is assumed that recursive enumeration will only be performed for the "enumerating the members of a group"
        // case, not the "groups to which a principal belongs" case, thus, this.recursive == true implies the former
        // (but this.recursive == false could imply either case).

        internal ADDNLinkedAttrSet(
                            string groupDN,
                            IEnumerable[] members,
                            string primaryGroupDN,
                            DirectorySearcher primaryGroupMembersSearcher,
                            bool recursive,
                            ADStoreCtx storeCtx)
        {
            GlobalDebug.WriteLineIf(GlobalDebug.Info,
                                    "ADDNLinkedAttrSet",
                                    "ADDNLinkedAttrSet: groupDN={0}, primaryGroupDN={1}, recursive={2}, PG queryFilter={3}, PG queryBase={4}",
                                    groupDN,
                                    (primaryGroupDN != null ? primaryGroupDN : "NULL"),
                                    recursive,
                                    (primaryGroupMembersSearcher != null ? primaryGroupMembersSearcher.Filter : "NULL"),
                                    (primaryGroupMembersSearcher != null ? primaryGroupMembersSearcher.SearchRoot.Path : "NULL"));

            _groupsVisited.Add(groupDN);    // so we don't revisit it
            _recursive = recursive;
            _storeCtx = storeCtx;
            _originalStoreCtx = storeCtx;

            if (null != members)
            {
                foreach (IEnumerable enumerator in members)
                {
                    _membersQueue.Enqueue(enumerator);
                    _originalMembers.Enqueue(enumerator);
                }
            }

            _members = null;

            _currentMembersSearcher = null;
            _primaryGroupDN = primaryGroupDN;
            if (primaryGroupDN == null)
                _returnedPrimaryGroup = true;    // so we don't bother trying to return the primary group

            _primaryGroupMembersSearcher = primaryGroupMembersSearcher;

            _expansionMode = ExpansionMode.Enum;
            _originalExpansionMode = _expansionMode;
        }
Exemplo n.º 17
0
 internal ADDNLinkedAttrSet(string groupDN, DirectorySearcher[] membersSearcher, string primaryGroupDN, DirectorySearcher primaryGroupMembersSearcher, bool recursive, ADStoreCtx storeCtx)
 {
     this.pathLock                     = new object();
     this.usersVisited                 = new Dictionary <string, bool>();
     this.groupsVisited                = new List <string>();
     this.groupsToVisit                = new List <string>();
     this.membersQueue                 = new Queue <IEnumerable>();
     this.originalMembers              = new Queue <IEnumerable>();
     this.atBeginning                  = true;
     this.foreignMembersCurrentGroup   = new List <DirectoryEntry>();
     this.fakePrincipalMembers         = new List <DirectoryEntry>();
     this.foreignGroups                = new List <GroupPrincipal>();
     this.memberSearchersQueue         = new Queue <DirectorySearcher>();
     this.memberSearchersQueueOriginal = new Queue <DirectorySearcher>();
     this.groupsVisited.Add(groupDN);
     this.recursive        = recursive;
     this.storeCtx         = storeCtx;
     this.originalStoreCtx = storeCtx;
     this.members          = null;
     this.originalMembers  = null;
     this.membersEnum      = null;
     this.primaryGroupDN   = primaryGroupDN;
     if (primaryGroupDN == null)
     {
         this.returnedPrimaryGroup = true;
     }
     if (membersSearcher != null)
     {
         DirectorySearcher[] directorySearcherArray = membersSearcher;
         for (int i = 0; i < (int)directorySearcherArray.Length; i++)
         {
             DirectorySearcher directorySearcher = directorySearcherArray[i];
             this.memberSearchersQueue.Enqueue(directorySearcher);
             this.memberSearchersQueueOriginal.Enqueue(directorySearcher);
         }
     }
     this.currentMembersSearcher      = null;
     this.primaryGroupMembersSearcher = primaryGroupMembersSearcher;
     this.expansionMode         = ExpansionMode.ASQ;
     this.originalExpansionMode = this.expansionMode;
 }
Exemplo n.º 18
0
        private StoreCtx CreateContextFromDirectoryEntry(DirectoryEntry entry)
        {
            StoreCtx sAMStoreCtx;

            if (!entry.Path.StartsWith("LDAP:", StringComparison.Ordinal))
            {
                sAMStoreCtx = new SAMStoreCtx(entry, true, this.username, this.password, this.options);
            }
            else
            {
                if (this.ContextType != ContextType.ApplicationDirectory)
                {
                    sAMStoreCtx = new ADStoreCtx(entry, true, this.username, this.password, this.options);
                }
                else
                {
                    sAMStoreCtx = new ADAMStoreCtx(entry, true, this.username, this.password, this.name, this.options);
                }
            }
            sAMStoreCtx.OwningContext = this;
            return(sAMStoreCtx);
        }
 internal ADDNConstraintLinkedAttrSet(ADDNConstraintLinkedAttrSet.ConstraintType constraint, object constraintData, string groupDN, DirectorySearcher[] membersSearcher, string primaryGroupDN, DirectorySearcher primaryGroupMembersSearcher, bool recursive, ADStoreCtx storeCtx) : base(groupDN, membersSearcher, primaryGroupDN, primaryGroupMembersSearcher, recursive, storeCtx)
 {
     this.constraint     = constraint;
     this.constraintData = constraintData;
 }
Exemplo n.º 20
0
 internal ADEntriesSet(SearchResultCollection src, ADStoreCtx storeCtx)
 {
     this.searchResults = src;
     this.storeCtx      = storeCtx;
     this.enumerator    = src.GetEnumerator();
 }
Exemplo n.º 21
0
		internal ADEntriesSet(SearchResultCollection src, ADStoreCtx storeCtx, object discriminant) : this(src, storeCtx)
		{
			this.discriminant = discriminant;
		}
Exemplo n.º 22
0
        internal ADEntriesSet(SearchResultCollection src, ADStoreCtx storeCtx, object discriminant) : this(src, storeCtx)
        {
            GlobalDebug.WriteLineIf(GlobalDebug.Info, "ADEntriesSet", "Ctor");

            _discriminant = discriminant;
        }
Exemplo n.º 23
0
		private bool ExpandForeignGroupSearcher()
		{
			GroupPrincipal item = this.foreignGroups[0];
			this.foreignGroups.RemoveAt(0);
			this.storeCtx = (ADStoreCtx)item.Context.QueryCtx;
			DirectorySearcher directorySearcher = SDSUtils.ConstructSearcher((DirectoryEntry)item.UnderlyingObject);
			directorySearcher.Filter = "(objectClass=*)";
			directorySearcher.SearchScope = SearchScope.Base;
			directorySearcher.AttributeScopeQuery = "member";
			directorySearcher.CacheResults = false;
			this.memberSearchersQueue.Enqueue(directorySearcher);
			string value = (string)((DirectoryEntry)item.UnderlyingObject).Properties["distinguishedName"].Value;
			this.groupsVisited.Add(value);
			return true;
		}
Exemplo n.º 24
0
        private void DoLDAPDirectoryInitNoContainer()
        {
            byte[] USERS_CONTAINER_GUID     = new byte[] { 0xa9, 0xd1, 0xca, 0x15, 0x76, 0x88, 0x11, 0xd1, 0xad, 0xed, 0x00, 0xc0, 0x4f, 0xd8, 0xd5, 0xcd };
            byte[] COMPUTERS_CONTAINER_GUID = new byte[] { 0xaa, 0x31, 0x28, 0x25, 0x76, 0x88, 0x11, 0xd1, 0xad, 0xed, 0x00, 0xc0, 0x4f, 0xd8, 0xd5, 0xcd };

            // The StoreCtxs that will be used in the PrincipalContext, and their associated DirectoryEntry objects.
            DirectoryEntry deUserGroupOrg = null;
            DirectoryEntry deComputer     = null;
            DirectoryEntry deBase         = null;

            ADStoreCtx storeCtxUserGroupOrg = null;
            ADStoreCtx storeCtxComputer     = null;
            ADStoreCtx storeCtxBase         = null;

            GlobalDebug.WriteLineIf(GlobalDebug.Info, "PrincipalContext", "Entering DoLDAPDirectoryInitNoContainer");

            //
            // Build a DirectoryEntry that represents the root of the domain.
            //

            // Use the RootDSE to find the default naming context
            DirectoryEntry deRootDse = null;
            string         adsPathBase;

            // use the servername if they gave us one, else let ADSI figure it out
            string serverName = "";

            if (_name != null)
            {
                serverName = _name + "/";
            }

            GlobalDebug.WriteLineIf(GlobalDebug.Info, "PrincipalContext", "DoLDAPDirectoryInitNoContainer: serverName is " + serverName);

            // use the options they specified
            AuthenticationTypes authTypes = SDSUtils.MapOptionsToAuthTypes(_options);

            GlobalDebug.WriteLineIf(GlobalDebug.Info, "PrincipalContext", "DoLDAPDirectoryInitNoContainer: authTypes is " + authTypes.ToString());

            try
            {
                deRootDse = new DirectoryEntry("LDAP://" + serverName + "rootDse", _username, _password, authTypes);

                // This will also detect if the server is down or nonexistent
                string domainNC = (string)deRootDse.Properties["defaultNamingContext"][0];
                adsPathBase = "LDAP://" + serverName + domainNC;

                GlobalDebug.WriteLineIf(GlobalDebug.Info, "PrincipalContext", "DoLDAPDirectoryInitNoContainer: domainNC is " + domainNC);
                GlobalDebug.WriteLineIf(GlobalDebug.Info, "PrincipalContext", "DoLDAPDirectoryInitNoContainer: adsPathBase is " + adsPathBase);
            }
            finally
            {
                // Don't allow the DE to leak
                deRootDse?.Dispose();
            }

            try
            {
                // Build a DE for the root of the domain using the retrieved naming context
                deBase = new DirectoryEntry(adsPathBase, _username, _password, authTypes);

                // Set the password port to the ssl port read off of the rootDSE.  Without this
                // password change/set won't work when we connect without SSL and ADAM is running
                // on non-standard port numbers.  We have already verified directory connectivity at this point
                // so this should always succeed.
                if (_serverProperties.portSSL > 0)
                {
                    deBase.Options.PasswordPort = _serverProperties.portSSL;
                }

                //
                // Use the wellKnownObjects attribute to determine the default location
                // for users and computers.
                //
                string adsPathUserGroupOrg = null;
                string adsPathComputer     = null;

                PropertyValueCollection wellKnownObjectValues = deBase.Properties["wellKnownObjects"];

                foreach (UnsafeNativeMethods.IADsDNWithBinary value in wellKnownObjectValues)
                {
                    if (Utils.AreBytesEqual(USERS_CONTAINER_GUID, (byte[])value.BinaryValue))
                    {
                        Debug.Assert(adsPathUserGroupOrg == null);
                        adsPathUserGroupOrg = "LDAP://" + serverName + value.DNString;

                        GlobalDebug.WriteLineIf(
                            GlobalDebug.Info,
                            "PrincipalContext",
                            "DoLDAPDirectoryInitNoContainer: found USER, adsPathUserGroupOrg is " + adsPathUserGroupOrg);
                    }

                    // Is it the computer container?
                    if (Utils.AreBytesEqual(COMPUTERS_CONTAINER_GUID, (byte[])value.BinaryValue))
                    {
                        Debug.Assert(adsPathComputer == null);
                        adsPathComputer = "LDAP://" + serverName + value.DNString;

                        GlobalDebug.WriteLineIf(
                            GlobalDebug.Info,
                            "PrincipalContext",
                            "DoLDAPDirectoryInitNoContainer: found COMPUTER, adsPathComputer is " + adsPathComputer);
                    }
                }

                if ((adsPathUserGroupOrg == null) || (adsPathComputer == null))
                {
                    // Something's wrong with the domain, it's not exposing the proper
                    // well-known object fields.
                    throw new PrincipalOperationException(SR.ContextNoWellKnownObjects);
                }

                //
                // Build DEs for the Users and Computers containers.
                // The Users container will also be used as the default for Groups.
                // The reason there are different contexts for groups, users and computers is so that
                // when a principal is created it will go into the appropriate default container.  This is so users don't
                // by default create principals in the root of their directory.  When a search happens the base context is used so that
                // the whole directory will be covered.
                //
                deUserGroupOrg = new DirectoryEntry(adsPathUserGroupOrg, _username, _password, authTypes);
                deComputer     = new DirectoryEntry(adsPathComputer, _username, _password, authTypes);

                StoreCtx userStore = CreateContextFromDirectoryEntry(deUserGroupOrg);

                _userCtx       = userStore;
                _groupCtx      = userStore;
                deUserGroupOrg = null;  // since we handed off ownership to the StoreCtx

                _computerCtx = CreateContextFromDirectoryEntry(deComputer);

                deComputer = null;

                _queryCtx = CreateContextFromDirectoryEntry(deBase);

                _connectedServer = ADUtils.GetServerName(deBase);

                deBase = null;
            }
            catch (Exception e)
            {
                GlobalDebug.WriteLineIf(GlobalDebug.Error,
                                        "PrincipalContext",
                                        "DoLDAPDirectoryInitNoContainer: caught exception of type "
                                        + e.GetType().ToString() +
                                        " and message " + e.Message);

                // Cleanup on failure.  Once a DE has been successfully handed off to a ADStoreCtx,
                // that ADStoreCtx will handle Dispose()'ing it
                deUserGroupOrg?.Dispose();
                deComputer?.Dispose();
                deBase?.Dispose();
                storeCtxUserGroupOrg?.Dispose();
                storeCtxComputer?.Dispose();
                storeCtxBase?.Dispose();

                throw;
            }
        }
Exemplo n.º 25
0
 internal ADEntriesSet(SearchResultCollection src, ADStoreCtx storeCtx, object discriminant) : this(src, storeCtx)
 {
     this.discriminant = discriminant;
 }
Exemplo n.º 26
0
		internal ADDNConstraintLinkedAttrSet(ADDNConstraintLinkedAttrSet.ConstraintType constraint, object constraintData, string groupDN, DirectorySearcher[] membersSearcher, string primaryGroupDN, DirectorySearcher primaryGroupMembersSearcher, bool recursive, ADStoreCtx storeCtx) : base(groupDN, membersSearcher, primaryGroupDN, primaryGroupMembersSearcher, recursive, storeCtx)
		{
			this.constraint = constraint;
			this.constraintData = constraintData;
		}
Exemplo n.º 27
0
        static ADAMStoreCtx()
        {
            bool flag;

            object[,] objArray = new object[3, 2];
            objArray[0, 0]     = "ms-DS-UserPasswordNotRequired";
            objArray[0, 1]     = "FALSE";
            objArray[1, 0]     = "msDS-UserDontExpirePassword";
            objArray[1, 1]     = "FALSE";
            objArray[2, 0]     = "ms-DS-UserEncryptedTextPasswordAllowed";
            objArray[2, 1]     = "FALSE";
            ADAMStoreCtx.PresenceStateTable       = objArray;
            object[,] fromLdapConverterDelegate   = new object[39, 4];
            fromLdapConverterDelegate[0, 0]       = "Principal.Description";
            fromLdapConverterDelegate[0, 1]       = "description";
            fromLdapConverterDelegate[0, 2]       = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.StringFromLdapConverter);
            fromLdapConverterDelegate[0, 3]       = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.StringToLdapConverter);
            fromLdapConverterDelegate[1, 0]       = "Principal.DisplayName";
            fromLdapConverterDelegate[1, 1]       = "displayName";
            fromLdapConverterDelegate[1, 2]       = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.StringFromLdapConverter);
            fromLdapConverterDelegate[1, 3]       = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.StringToLdapConverter);
            fromLdapConverterDelegate[2, 0]       = "Principal.DistinguishedName";
            fromLdapConverterDelegate[2, 1]       = "distinguishedName";
            fromLdapConverterDelegate[2, 2]       = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.StringFromLdapConverter);
            fromLdapConverterDelegate[2, 3]       = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.StringToLdapConverter);
            fromLdapConverterDelegate[3, 0]       = "Principal.Sid";
            fromLdapConverterDelegate[3, 1]       = "objectSid";
            fromLdapConverterDelegate[3, 2]       = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.SidFromLdapConverter);
            fromLdapConverterDelegate[4, 0]       = "Principal.SamAccountName";
            fromLdapConverterDelegate[4, 1]       = "name";
            fromLdapConverterDelegate[5, 0]       = "Principal.UserPrincipalName";
            fromLdapConverterDelegate[5, 1]       = "userPrincipalName";
            fromLdapConverterDelegate[5, 2]       = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.StringFromLdapConverter);
            fromLdapConverterDelegate[5, 3]       = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.StringToLdapConverter);
            fromLdapConverterDelegate[6, 0]       = "Principal.Guid";
            fromLdapConverterDelegate[6, 1]       = "objectGuid";
            fromLdapConverterDelegate[6, 2]       = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.GuidFromLdapConverter);
            fromLdapConverterDelegate[7, 0]       = "Principal.StructuralObjectClass";
            fromLdapConverterDelegate[7, 1]       = "objectClass";
            fromLdapConverterDelegate[7, 2]       = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.ObjectClassFromLdapConverter);
            fromLdapConverterDelegate[8, 0]       = "Principal.Name";
            fromLdapConverterDelegate[8, 1]       = "name";
            fromLdapConverterDelegate[8, 2]       = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.StringFromLdapConverter);
            fromLdapConverterDelegate[8, 3]       = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.StringToLdapConverter);
            fromLdapConverterDelegate[9, 0]       = "Principal.ExtensionCache";
            fromLdapConverterDelegate[9, 3]       = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.ExtensionCacheToLdapConverter);
            fromLdapConverterDelegate[10, 0]      = "AuthenticablePrincipal.Enabled";
            fromLdapConverterDelegate[10, 1]      = "msDS-UserAccountDisabled";
            fromLdapConverterDelegate[10, 2]      = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.AcctDisabledFromLdapConverter);
            fromLdapConverterDelegate[10, 3]      = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.AcctDisabledToLdapConverter);
            fromLdapConverterDelegate[11, 0]      = "AuthenticablePrincipal.Certificates";
            fromLdapConverterDelegate[11, 1]      = "userCertificate";
            fromLdapConverterDelegate[11, 2]      = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.CertFromLdapConverter);
            fromLdapConverterDelegate[11, 3]      = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.CertToLdap);
            fromLdapConverterDelegate[12, 0]      = "GroupPrincipal.IsSecurityGroup";
            fromLdapConverterDelegate[12, 1]      = "groupType";
            fromLdapConverterDelegate[12, 2]      = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.GroupTypeFromLdapConverter);
            fromLdapConverterDelegate[12, 3]      = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.GroupTypeToLdapConverter);
            fromLdapConverterDelegate[13, 0]      = "GroupPrincipal.GroupScope";
            fromLdapConverterDelegate[13, 1]      = "groupType";
            fromLdapConverterDelegate[13, 2]      = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.GroupTypeFromLdapConverter);
            fromLdapConverterDelegate[13, 3]      = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.GroupTypeToLdapConverter);
            fromLdapConverterDelegate[14, 0]      = "UserPrincipal.GivenName";
            fromLdapConverterDelegate[14, 1]      = "givenName";
            fromLdapConverterDelegate[14, 2]      = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.StringFromLdapConverter);
            fromLdapConverterDelegate[14, 3]      = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.StringToLdapConverter);
            fromLdapConverterDelegate[15, 0]      = "UserPrincipal.MiddleName";
            fromLdapConverterDelegate[15, 1]      = "middleName";
            fromLdapConverterDelegate[15, 2]      = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.StringFromLdapConverter);
            fromLdapConverterDelegate[15, 3]      = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.StringToLdapConverter);
            fromLdapConverterDelegate[16, 0]      = "UserPrincipal.Surname";
            fromLdapConverterDelegate[16, 1]      = "sn";
            fromLdapConverterDelegate[16, 2]      = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.StringFromLdapConverter);
            fromLdapConverterDelegate[16, 3]      = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.StringToLdapConverter);
            fromLdapConverterDelegate[17, 0]      = "UserPrincipal.EmailAddress";
            fromLdapConverterDelegate[17, 1]      = "mail";
            fromLdapConverterDelegate[17, 2]      = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.StringFromLdapConverter);
            fromLdapConverterDelegate[17, 3]      = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.StringToLdapConverter);
            fromLdapConverterDelegate[18, 0]      = "UserPrincipal.VoiceTelephoneNumber";
            fromLdapConverterDelegate[18, 1]      = "telephoneNumber";
            fromLdapConverterDelegate[18, 2]      = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.StringFromLdapConverter);
            fromLdapConverterDelegate[18, 3]      = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.StringToLdapConverter);
            fromLdapConverterDelegate[19, 0]      = "UserPrincipal.EmployeeId";
            fromLdapConverterDelegate[19, 1]      = "employeeID";
            fromLdapConverterDelegate[19, 2]      = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.StringFromLdapConverter);
            fromLdapConverterDelegate[19, 3]      = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.StringToLdapConverter);
            fromLdapConverterDelegate[20, 0]      = "ComputerPrincipal.ServicePrincipalNames";
            fromLdapConverterDelegate[20, 1]      = "servicePrincipalName";
            fromLdapConverterDelegate[20, 2]      = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.MultiStringFromLdapConverter);
            fromLdapConverterDelegate[20, 3]      = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.MultiStringToLdapConverter);
            fromLdapConverterDelegate[21, 0]      = "AuthenticablePrincipal.AccountInfo.AccountLockoutTime";
            fromLdapConverterDelegate[21, 1]      = "lockoutTime";
            fromLdapConverterDelegate[21, 2]      = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.GenericDateTimeFromLdapConverter);
            fromLdapConverterDelegate[22, 0]      = "AuthenticablePrincipal.AccountInfo.LastLogon";
            fromLdapConverterDelegate[22, 1]      = "lastLogon";
            fromLdapConverterDelegate[22, 2]      = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.LastLogonFromLdapConverter);
            fromLdapConverterDelegate[23, 0]      = "AuthenticablePrincipal.AccountInfo.LastLogon";
            fromLdapConverterDelegate[23, 1]      = "lastLogonTimestamp";
            fromLdapConverterDelegate[23, 2]      = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.LastLogonFromLdapConverter);
            fromLdapConverterDelegate[24, 0]      = "AuthenticablePrincipal.AccountInfo.PermittedWorkstations";
            fromLdapConverterDelegate[24, 1]      = "userWorkstations";
            fromLdapConverterDelegate[25, 0]      = "AuthenticablePrincipal.AccountInfo.PermittedLogonTimes";
            fromLdapConverterDelegate[25, 1]      = "logonHours";
            fromLdapConverterDelegate[26, 0]      = "AuthenticablePrincipal.AccountInfo.AccountExpirationDate";
            fromLdapConverterDelegate[26, 1]      = "accountExpires";
            fromLdapConverterDelegate[26, 2]      = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.AcctExpirFromLdapConverter);
            fromLdapConverterDelegate[26, 3]      = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.AcctExpirToLdapConverter);
            fromLdapConverterDelegate[27, 0]      = "AuthenticablePrincipal.AccountInfo.SmartcardLogonRequired";
            fromLdapConverterDelegate[27, 1]      = "userAccountControl";
            fromLdapConverterDelegate[28, 0]      = "AuthenticablePrincipal.AccountInfo.DelegationPermitted";
            fromLdapConverterDelegate[28, 1]      = "userAccountControl";
            fromLdapConverterDelegate[29, 0]      = "AuthenticablePrincipal.AccountInfo.BadLogonCount";
            fromLdapConverterDelegate[29, 1]      = "badPwdCount";
            fromLdapConverterDelegate[29, 2]      = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.IntFromLdapConverter);
            fromLdapConverterDelegate[30, 0]      = "AuthenticablePrincipal.AccountInfo.HomeDirectory";
            fromLdapConverterDelegate[30, 1]      = "homeDirectory";
            fromLdapConverterDelegate[31, 0]      = "AuthenticablePrincipal.AccountInfo.HomeDrive";
            fromLdapConverterDelegate[31, 1]      = "homeDrive";
            fromLdapConverterDelegate[32, 0]      = "AuthenticablePrincipal.AccountInfo.ScriptPath";
            fromLdapConverterDelegate[32, 1]      = "scriptPath";
            fromLdapConverterDelegate[33, 0]      = "AuthenticablePrincipal.PasswordInfo.LastPasswordSet";
            fromLdapConverterDelegate[33, 1]      = "pwdLastSet";
            fromLdapConverterDelegate[33, 2]      = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.GenericDateTimeFromLdapConverter);
            fromLdapConverterDelegate[34, 0]      = "AuthenticablePrincipal.PasswordInfo.LastBadPasswordAttempt";
            fromLdapConverterDelegate[34, 1]      = "badPasswordTime";
            fromLdapConverterDelegate[34, 2]      = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.GenericDateTimeFromLdapConverter);
            fromLdapConverterDelegate[35, 0]      = "AuthenticablePrincipal.PasswordInfo.PasswordNotRequired";
            fromLdapConverterDelegate[35, 1]      = "ms-DS-UserPasswordNotRequired";
            fromLdapConverterDelegate[35, 2]      = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.BoolFromLdapConverter);
            fromLdapConverterDelegate[35, 3]      = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.BoolToLdapConverter);
            fromLdapConverterDelegate[36, 0]      = "AuthenticablePrincipal.PasswordInfo.PasswordNeverExpires";
            fromLdapConverterDelegate[36, 1]      = "msDS-UserDontExpirePassword";
            fromLdapConverterDelegate[36, 2]      = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.BoolFromLdapConverter);
            fromLdapConverterDelegate[36, 3]      = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.BoolToLdapConverter);
            fromLdapConverterDelegate[37, 0]      = "AuthenticablePrincipal.PasswordInfo.UserCannotChangePassword";
            fromLdapConverterDelegate[37, 1]      = "ntSecurityDescriptor";
            fromLdapConverterDelegate[37, 3]      = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.CannotChangePwdToLdapConverter);
            fromLdapConverterDelegate[38, 0]      = "AuthenticablePrincipal.PasswordInfo.AllowReversiblePasswordEncryption";
            fromLdapConverterDelegate[38, 1]      = "ms-DS-UserEncryptedTextPasswordAllowed";
            fromLdapConverterDelegate[38, 2]      = new ADStoreCtx.FromLdapConverterDelegate(ADStoreCtx.BoolFromLdapConverter);
            fromLdapConverterDelegate[38, 3]      = new ADStoreCtx.ToLdapConverterDelegate(ADStoreCtx.BoolToLdapConverter);
            ADAMStoreCtx.propertyMappingTableRaw  = fromLdapConverterDelegate;
            object[,] filterConverterDelegate     = new object[37, 3];
            filterConverterDelegate[0, 0]         = typeof(DescriptionFilter);
            filterConverterDelegate[0, 1]         = "description";
            filterConverterDelegate[0, 2]         = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.StringConverter);
            filterConverterDelegate[1, 0]         = typeof(DisplayNameFilter);
            filterConverterDelegate[1, 1]         = "displayName";
            filterConverterDelegate[1, 2]         = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.StringConverter);
            filterConverterDelegate[2, 0]         = typeof(IdentityClaimFilter);
            filterConverterDelegate[2, 1]         = "";
            filterConverterDelegate[2, 2]         = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.IdentityClaimConverter);
            filterConverterDelegate[3, 0]         = typeof(DistinguishedNameFilter);
            filterConverterDelegate[3, 1]         = "distinguishedName";
            filterConverterDelegate[3, 2]         = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.StringConverter);
            filterConverterDelegate[4, 0]         = typeof(GuidFilter);
            filterConverterDelegate[4, 1]         = "objectGuid";
            filterConverterDelegate[4, 2]         = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.GuidConverter);
            filterConverterDelegate[5, 0]         = typeof(UserPrincipalNameFilter);
            filterConverterDelegate[5, 1]         = "userPrincipalName";
            filterConverterDelegate[5, 2]         = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.StringConverter);
            filterConverterDelegate[6, 0]         = typeof(StructuralObjectClassFilter);
            filterConverterDelegate[6, 1]         = "objectClass";
            filterConverterDelegate[6, 2]         = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.StringConverter);
            filterConverterDelegate[7, 0]         = typeof(NameFilter);
            filterConverterDelegate[7, 1]         = "name";
            filterConverterDelegate[7, 2]         = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.StringConverter);
            filterConverterDelegate[8, 0]         = typeof(CertificateFilter);
            filterConverterDelegate[8, 1]         = "";
            filterConverterDelegate[8, 2]         = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.CertificateConverter);
            filterConverterDelegate[9, 0]         = typeof(AuthPrincEnabledFilter);
            filterConverterDelegate[9, 1]         = "msDS-UserAccountDisabled";
            filterConverterDelegate[9, 2]         = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.AcctDisabledConverter);
            filterConverterDelegate[10, 0]        = typeof(PermittedWorkstationFilter);
            filterConverterDelegate[10, 1]        = "userWorkstations";
            filterConverterDelegate[10, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.StringConverter);
            filterConverterDelegate[11, 0]        = typeof(PermittedLogonTimesFilter);
            filterConverterDelegate[11, 1]        = "logonHours";
            filterConverterDelegate[11, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.BinaryConverter);
            filterConverterDelegate[12, 0]        = typeof(ExpirationDateFilter);
            filterConverterDelegate[12, 1]        = "accountExpires";
            filterConverterDelegate[12, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.ExpirationDateConverter);
            filterConverterDelegate[13, 0]        = typeof(SmartcardLogonRequiredFilter);
            filterConverterDelegate[13, 1]        = "userAccountControl";
            filterConverterDelegate[13, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.UserAccountControlConverter);
            filterConverterDelegate[14, 0]        = typeof(DelegationPermittedFilter);
            filterConverterDelegate[14, 1]        = "userAccountControl";
            filterConverterDelegate[14, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.UserAccountControlConverter);
            filterConverterDelegate[15, 0]        = typeof(HomeDirectoryFilter);
            filterConverterDelegate[15, 1]        = "homeDirectory";
            filterConverterDelegate[15, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.StringConverter);
            filterConverterDelegate[16, 0]        = typeof(HomeDriveFilter);
            filterConverterDelegate[16, 1]        = "homeDrive";
            filterConverterDelegate[16, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.StringConverter);
            filterConverterDelegate[17, 0]        = typeof(ScriptPathFilter);
            filterConverterDelegate[17, 1]        = "scriptPath";
            filterConverterDelegate[17, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.StringConverter);
            filterConverterDelegate[18, 0]        = typeof(PasswordNotRequiredFilter);
            filterConverterDelegate[18, 1]        = "ms-DS-UserPasswordNotRequired";
            filterConverterDelegate[18, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.DefaultValueBoolConverter);
            filterConverterDelegate[19, 0]        = typeof(PasswordNeverExpiresFilter);
            filterConverterDelegate[19, 1]        = "msDS-UserDontExpirePassword";
            filterConverterDelegate[19, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.DefaultValueBoolConverter);
            filterConverterDelegate[20, 0]        = typeof(CannotChangePasswordFilter);
            filterConverterDelegate[20, 1]        = "userAccountControl";
            filterConverterDelegate[20, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.UserAccountControlConverter);
            filterConverterDelegate[21, 0]        = typeof(AllowReversiblePasswordEncryptionFilter);
            filterConverterDelegate[21, 1]        = "ms-DS-UserEncryptedTextPasswordAllowed";
            filterConverterDelegate[21, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.DefaultValueBoolConverter);
            filterConverterDelegate[22, 0]        = typeof(GivenNameFilter);
            filterConverterDelegate[22, 1]        = "givenName";
            filterConverterDelegate[22, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.StringConverter);
            filterConverterDelegate[23, 0]        = typeof(MiddleNameFilter);
            filterConverterDelegate[23, 1]        = "middleName";
            filterConverterDelegate[23, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.StringConverter);
            filterConverterDelegate[24, 0]        = typeof(SurnameFilter);
            filterConverterDelegate[24, 1]        = "sn";
            filterConverterDelegate[24, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.StringConverter);
            filterConverterDelegate[25, 0]        = typeof(EmailAddressFilter);
            filterConverterDelegate[25, 1]        = "mail";
            filterConverterDelegate[25, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.StringConverter);
            filterConverterDelegate[26, 0]        = typeof(VoiceTelephoneNumberFilter);
            filterConverterDelegate[26, 1]        = "telephoneNumber";
            filterConverterDelegate[26, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.StringConverter);
            filterConverterDelegate[27, 0]        = typeof(EmployeeIDFilter);
            filterConverterDelegate[27, 1]        = "employeeID";
            filterConverterDelegate[27, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.StringConverter);
            filterConverterDelegate[28, 0]        = typeof(GroupIsSecurityGroupFilter);
            filterConverterDelegate[28, 1]        = "groupType";
            filterConverterDelegate[28, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.GroupTypeConverter);
            filterConverterDelegate[29, 0]        = typeof(GroupScopeFilter);
            filterConverterDelegate[29, 1]        = "groupType";
            filterConverterDelegate[29, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.GroupTypeConverter);
            filterConverterDelegate[30, 0]        = typeof(ServicePrincipalNameFilter);
            filterConverterDelegate[30, 1]        = "servicePrincipalName";
            filterConverterDelegate[30, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.StringConverter);
            filterConverterDelegate[31, 0]        = typeof(ExtensionCacheFilter);
            filterConverterDelegate[31, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.ExtensionCacheConverter);
            filterConverterDelegate[32, 0]        = typeof(BadPasswordAttemptFilter);
            filterConverterDelegate[32, 1]        = "badPasswordTime";
            filterConverterDelegate[32, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.DefaultValutMatchingDateTimeConverter);
            filterConverterDelegate[33, 0]        = typeof(ExpiredAccountFilter);
            filterConverterDelegate[33, 1]        = "accountExpires";
            filterConverterDelegate[33, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.MatchingDateTimeConverter);
            filterConverterDelegate[34, 0]        = typeof(LastLogonTimeFilter);
            filterConverterDelegate[34, 1]        = "lastLogonTimestamp";
            filterConverterDelegate[34, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.DefaultValutMatchingDateTimeConverter);
            filterConverterDelegate[35, 0]        = typeof(LockoutTimeFilter);
            filterConverterDelegate[35, 1]        = "lockoutTime";
            filterConverterDelegate[35, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.DefaultValutMatchingDateTimeConverter);
            filterConverterDelegate[36, 0]        = typeof(PasswordSetTimeFilter);
            filterConverterDelegate[36, 1]        = "pwdLastSet";
            filterConverterDelegate[36, 2]        = new ADStoreCtx.FilterConverterDelegate(ADStoreCtx.DefaultValutMatchingDateTimeConverter);
            ADAMStoreCtx.filterPropertiesTableRaw = filterConverterDelegate;
            ADStoreCtx.LoadFilterMappingTable(1, ADAMStoreCtx.filterPropertiesTableRaw);
            ADStoreCtx.LoadPropertyMappingTable(1, ADAMStoreCtx.propertyMappingTableRaw);
            if (ADStoreCtx.NonPresentAttrDefaultStateMapping == null)
            {
                ADStoreCtx.NonPresentAttrDefaultStateMapping = new Dictionary <string, bool>();
            }
            for (int i = 0; i < ADAMStoreCtx.PresenceStateTable.GetLength(0); i++)
            {
                string presenceStateTable = ADAMStoreCtx.PresenceStateTable[i, 0] as string;
                string str = ADAMStoreCtx.PresenceStateTable[i, 1] as string;
                Dictionary <string, bool> nonPresentAttrDefaultStateMapping = ADStoreCtx.NonPresentAttrDefaultStateMapping;
                string str1 = presenceStateTable;
                if (str == "FALSE")
                {
                    flag = false;
                }
                else
                {
                    flag = true;
                }
                nonPresentAttrDefaultStateMapping.Add(str1, flag);
            }
        }
Exemplo n.º 28
0
 internal override void Reset()
 {
     if (!this.atBeginning)
     {
         this.usersVisited.Clear();
         this.groupsToVisit.Clear();
         string item = this.groupsVisited[0];
         this.groupsVisited.Clear();
         this.groupsVisited.Add(item);
         this.members     = null;
         this.membersEnum = null;
         if (this.originalMembers != null)
         {
             this.membersQueue.Clear();
             foreach (IEnumerable enumerable in enumerable)
             {
                 this.membersQueue.Enqueue(enumerable);
                 IEnumerator enumerator = enumerable.GetEnumerator();
                 enumerator.Reset();
             }
         }
         this.expansionMode = this.originalExpansionMode;
         this.storeCtx      = this.originalStoreCtx;
         this.current       = null;
         if (this.primaryGroupDN != null)
         {
             this.returnedPrimaryGroup = false;
         }
         this.foreignMembersCurrentGroup.Clear();
         this.fakePrincipalMembers.Clear();
         if (this.foreignMembersToReturn != null)
         {
             this.foreignMembersToReturn.Clear();
         }
         this.currentForeignPrincipal = null;
         this.currentForeignDE        = null;
         this.foreignGroups.Clear();
         this.queryMembersResultEnumerator = null;
         if (this.queryMembersResults != null)
         {
             this.queryMembersResults.Dispose();
             this.queryMembersResults = null;
         }
         if (this.currentMembersSearcher != null)
         {
             this.currentMembersSearcher.Dispose();
             this.currentMembersSearcher = null;
         }
         this.memberSearchResultsEnumerator = null;
         if (this.memberSearchResults != null)
         {
             this.memberSearchResults.Dispose();
             this.memberSearchResults = null;
         }
         if (this.memberSearchersQueue != null)
         {
             foreach (DirectorySearcher directorySearcher in this.memberSearchersQueue)
             {
                 directorySearcher.Dispose();
             }
             this.memberSearchersQueue.Clear();
             if (this.memberSearchersQueueOriginal != null)
             {
                 foreach (DirectorySearcher directorySearcher1 in this.memberSearchersQueueOriginal)
                 {
                     this.memberSearchersQueue.Enqueue(directorySearcher1);
                 }
             }
         }
         this.atBeginning = true;
     }
 }
Exemplo n.º 29
0
		internal override ResultSetBookmark BookmarkAndReset()
		{
			ADDNLinkedAttrSetBookmark aDDNLinkedAttrSetBookmark = new ADDNLinkedAttrSetBookmark();
			aDDNLinkedAttrSetBookmark.usersVisited = this.usersVisited;
			this.usersVisited = new Dictionary<string, bool>();
			aDDNLinkedAttrSetBookmark.groupsToVisit = this.groupsToVisit;
			this.groupsToVisit = new List<string>();
			string item = this.groupsVisited[0];
			aDDNLinkedAttrSetBookmark.groupsVisited = this.groupsVisited;
			this.groupsVisited = new List<string>();
			this.groupsVisited.Add(item);
			aDDNLinkedAttrSetBookmark.expansionMode = this.expansionMode;
			aDDNLinkedAttrSetBookmark.members = this.members;
			aDDNLinkedAttrSetBookmark.membersEnum = this.membersEnum;
			this.members = null;
			this.membersEnum = null;
			if (this.membersQueue != null)
			{
				aDDNLinkedAttrSetBookmark.membersQueue = new Queue<IEnumerable>(this.membersQueue.Count);
				foreach (IEnumerable enumerable in this.membersQueue)
				{
					aDDNLinkedAttrSetBookmark.membersQueue.Enqueue(enumerable);
				}
			}
			if (this.membersQueue != null)
			{
				this.membersQueue.Clear();
				if (this.originalMembers != null)
				{
					foreach (IEnumerable enumerable1 in this.originalMembers)
					{
						this.membersQueue.Enqueue(enumerable1);
						IEnumerator enumerator = enumerable1.GetEnumerator();
						enumerator.Reset();
					}
				}
			}
			aDDNLinkedAttrSetBookmark.storeCtx = this.storeCtx;
			this.expansionMode = this.originalExpansionMode;
			if (this.currentMembersSearcher != null)
			{
				this.currentMembersSearcher.Dispose();
				this.currentMembersSearcher = null;
			}
			this.storeCtx = this.originalStoreCtx;
			aDDNLinkedAttrSetBookmark.current = this.current;
			aDDNLinkedAttrSetBookmark.returnedPrimaryGroup = this.returnedPrimaryGroup;
			this.current = null;
			if (this.primaryGroupDN != null)
			{
				this.returnedPrimaryGroup = false;
			}
			aDDNLinkedAttrSetBookmark.foreignMembersCurrentGroup = this.foreignMembersCurrentGroup;
			aDDNLinkedAttrSetBookmark.fakePrincipalMembers = this.fakePrincipalMembers;
			aDDNLinkedAttrSetBookmark.foreignMembersToReturn = this.foreignMembersToReturn;
			aDDNLinkedAttrSetBookmark.currentForeignPrincipal = this.currentForeignPrincipal;
			aDDNLinkedAttrSetBookmark.currentForeignDE = this.currentForeignDE;
			this.foreignMembersCurrentGroup = new List<DirectoryEntry>();
			this.fakePrincipalMembers = new List<DirectoryEntry>();
			this.currentForeignDE = null;
			aDDNLinkedAttrSetBookmark.foreignGroups = this.foreignGroups;
			this.foreignGroups = new List<GroupPrincipal>();
			aDDNLinkedAttrSetBookmark.queryMembersResults = this.queryMembersResults;
			aDDNLinkedAttrSetBookmark.queryMembersResultEnumerator = this.queryMembersResultEnumerator;
			this.queryMembersResults = null;
			this.queryMembersResultEnumerator = null;
			aDDNLinkedAttrSetBookmark.memberSearchResults = this.memberSearchResults;
			aDDNLinkedAttrSetBookmark.memberSearchResultsEnumerator = this.memberSearchResultsEnumerator;
			this.memberSearchResults = null;
			this.memberSearchResultsEnumerator = null;
			if (this.memberSearchersQueue != null)
			{
				aDDNLinkedAttrSetBookmark.memberSearcherQueue = new Queue<DirectorySearcher>(this.memberSearchersQueue.Count);
				foreach (DirectorySearcher directorySearcher in this.memberSearchersQueue)
				{
					aDDNLinkedAttrSetBookmark.memberSearcherQueue.Enqueue(directorySearcher);
				}
			}
			if (this.memberSearchersQueueOriginal != null)
			{
				this.memberSearchersQueue.Clear();
				foreach (DirectorySearcher directorySearcher1 in this.memberSearchersQueueOriginal)
				{
					this.memberSearchersQueue.Enqueue(directorySearcher1);
				}
			}
			aDDNLinkedAttrSetBookmark.atBeginning = this.atBeginning;
			this.atBeginning = true;
			return aDDNLinkedAttrSetBookmark;
		}
Exemplo n.º 30
0
        internal ADEntriesSet(SearchResultCollection src, ADStoreCtx storeCtx, object discriminant) : this(src, storeCtx)
        {
            GlobalDebug.WriteLineIf(GlobalDebug.Info, "ADEntriesSet", "Ctor");

            _discriminant = discriminant;
        }
Exemplo n.º 31
0
        internal override ResultSetBookmark BookmarkAndReset()
        {
            ADDNLinkedAttrSetBookmark aDDNLinkedAttrSetBookmark = new ADDNLinkedAttrSetBookmark();

            aDDNLinkedAttrSetBookmark.usersVisited = this.usersVisited;
            this.usersVisited = new Dictionary <string, bool>();
            aDDNLinkedAttrSetBookmark.groupsToVisit = this.groupsToVisit;
            this.groupsToVisit = new List <string>();
            string item = this.groupsVisited[0];

            aDDNLinkedAttrSetBookmark.groupsVisited = this.groupsVisited;
            this.groupsVisited = new List <string>();
            this.groupsVisited.Add(item);
            aDDNLinkedAttrSetBookmark.expansionMode = this.expansionMode;
            aDDNLinkedAttrSetBookmark.members       = this.members;
            aDDNLinkedAttrSetBookmark.membersEnum   = this.membersEnum;
            this.members     = null;
            this.membersEnum = null;
            if (this.membersQueue != null)
            {
                aDDNLinkedAttrSetBookmark.membersQueue = new Queue <IEnumerable>(this.membersQueue.Count);
                foreach (IEnumerable enumerable in this.membersQueue)
                {
                    aDDNLinkedAttrSetBookmark.membersQueue.Enqueue(enumerable);
                }
            }
            if (this.membersQueue != null)
            {
                this.membersQueue.Clear();
                if (this.originalMembers != null)
                {
                    foreach (IEnumerable enumerable1 in this.originalMembers)
                    {
                        this.membersQueue.Enqueue(enumerable1);
                        IEnumerator enumerator = enumerable1.GetEnumerator();
                        enumerator.Reset();
                    }
                }
            }
            aDDNLinkedAttrSetBookmark.storeCtx = this.storeCtx;
            this.expansionMode = this.originalExpansionMode;
            if (this.currentMembersSearcher != null)
            {
                this.currentMembersSearcher.Dispose();
                this.currentMembersSearcher = null;
            }
            this.storeCtx = this.originalStoreCtx;
            aDDNLinkedAttrSetBookmark.current = this.current;
            aDDNLinkedAttrSetBookmark.returnedPrimaryGroup = this.returnedPrimaryGroup;
            this.current = null;
            if (this.primaryGroupDN != null)
            {
                this.returnedPrimaryGroup = false;
            }
            aDDNLinkedAttrSetBookmark.foreignMembersCurrentGroup = this.foreignMembersCurrentGroup;
            aDDNLinkedAttrSetBookmark.fakePrincipalMembers       = this.fakePrincipalMembers;
            aDDNLinkedAttrSetBookmark.foreignMembersToReturn     = this.foreignMembersToReturn;
            aDDNLinkedAttrSetBookmark.currentForeignPrincipal    = this.currentForeignPrincipal;
            aDDNLinkedAttrSetBookmark.currentForeignDE           = this.currentForeignDE;
            this.foreignMembersCurrentGroup         = new List <DirectoryEntry>();
            this.fakePrincipalMembers               = new List <DirectoryEntry>();
            this.currentForeignDE                   = null;
            aDDNLinkedAttrSetBookmark.foreignGroups = this.foreignGroups;
            this.foreignGroups = new List <GroupPrincipal>();
            aDDNLinkedAttrSetBookmark.queryMembersResults          = this.queryMembersResults;
            aDDNLinkedAttrSetBookmark.queryMembersResultEnumerator = this.queryMembersResultEnumerator;
            this.queryMembersResults                                = null;
            this.queryMembersResultEnumerator                       = null;
            aDDNLinkedAttrSetBookmark.memberSearchResults           = this.memberSearchResults;
            aDDNLinkedAttrSetBookmark.memberSearchResultsEnumerator = this.memberSearchResultsEnumerator;
            this.memberSearchResults                                = null;
            this.memberSearchResultsEnumerator                      = null;
            if (this.memberSearchersQueue != null)
            {
                aDDNLinkedAttrSetBookmark.memberSearcherQueue = new Queue <DirectorySearcher>(this.memberSearchersQueue.Count);
                foreach (DirectorySearcher directorySearcher in this.memberSearchersQueue)
                {
                    aDDNLinkedAttrSetBookmark.memberSearcherQueue.Enqueue(directorySearcher);
                }
            }
            if (this.memberSearchersQueueOriginal != null)
            {
                this.memberSearchersQueue.Clear();
                foreach (DirectorySearcher directorySearcher1 in this.memberSearchersQueueOriginal)
                {
                    this.memberSearchersQueue.Enqueue(directorySearcher1);
                }
            }
            aDDNLinkedAttrSetBookmark.atBeginning = this.atBeginning;
            this.atBeginning = true;
            return(aDDNLinkedAttrSetBookmark);
        }
Exemplo n.º 32
0
        private StoreCtx CreateContextFromDirectoryEntry(DirectoryEntry entry)
        {
            StoreCtx storeCtx;

            Debug.Assert(entry != null);

            GlobalDebug.WriteLineIf(GlobalDebug.Info, "PrincipalContext", "CreateContextFromDirectoryEntry: path is " + entry.Path);

            if (entry.Path.StartsWith("LDAP:", StringComparison.Ordinal))
            {
                if (this.ContextType == ContextType.ApplicationDirectory)
                {
                    storeCtx = new ADAMStoreCtx(entry, true, _username, _password, _name, _options);
                }
                else
                {
                    storeCtx = new ADStoreCtx(entry, true, _username, _password, _options);
                }
            }
            else
            {
                Debug.Assert(entry.Path.StartsWith("WinNT:", StringComparison.Ordinal));
                storeCtx = new SAMStoreCtx(entry, true, _username, _password, _options);
            }

            storeCtx.OwningContext = this;
            return storeCtx;
        }
Exemplo n.º 33
0
		internal override void RestoreBookmark(ResultSetBookmark bookmark)
		{
			ADDNLinkedAttrSetBookmark aDDNLinkedAttrSetBookmark = (ADDNLinkedAttrSetBookmark)bookmark;
			this.usersVisited = aDDNLinkedAttrSetBookmark.usersVisited;
			this.groupsToVisit = aDDNLinkedAttrSetBookmark.groupsToVisit;
			this.groupsVisited = aDDNLinkedAttrSetBookmark.groupsVisited;
			this.storeCtx = aDDNLinkedAttrSetBookmark.storeCtx;
			this.current = aDDNLinkedAttrSetBookmark.current;
			this.returnedPrimaryGroup = aDDNLinkedAttrSetBookmark.returnedPrimaryGroup;
			this.foreignMembersCurrentGroup = aDDNLinkedAttrSetBookmark.foreignMembersCurrentGroup;
			this.fakePrincipalMembers = aDDNLinkedAttrSetBookmark.fakePrincipalMembers;
			this.foreignMembersToReturn = aDDNLinkedAttrSetBookmark.foreignMembersToReturn;
			this.currentForeignPrincipal = aDDNLinkedAttrSetBookmark.currentForeignPrincipal;
			this.currentForeignDE = aDDNLinkedAttrSetBookmark.currentForeignDE;
			this.foreignGroups = aDDNLinkedAttrSetBookmark.foreignGroups;
			if (this.queryMembersResults != null)
			{
				this.queryMembersResults.Dispose();
			}
			this.queryMembersResults = aDDNLinkedAttrSetBookmark.queryMembersResults;
			this.queryMembersResultEnumerator = aDDNLinkedAttrSetBookmark.queryMembersResultEnumerator;
			this.memberSearchResults = aDDNLinkedAttrSetBookmark.memberSearchResults;
			this.memberSearchResultsEnumerator = aDDNLinkedAttrSetBookmark.memberSearchResultsEnumerator;
			this.atBeginning = aDDNLinkedAttrSetBookmark.atBeginning;
			this.expansionMode = aDDNLinkedAttrSetBookmark.expansionMode;
			this.members = aDDNLinkedAttrSetBookmark.members;
			this.membersEnum = aDDNLinkedAttrSetBookmark.membersEnum;
			if (this.membersQueue != null)
			{
				this.membersQueue.Clear();
				if (aDDNLinkedAttrSetBookmark.membersQueue != null)
				{
					foreach (IEnumerable enumerable in aDDNLinkedAttrSetBookmark.membersQueue)
					{
						this.membersQueue.Enqueue(enumerable);
					}
				}
			}
			if (this.memberSearchersQueue != null)
			{
				foreach (DirectorySearcher directorySearcher in this.memberSearchersQueue)
				{
					directorySearcher.Dispose();
				}
				this.memberSearchersQueue.Clear();
				if (aDDNLinkedAttrSetBookmark.memberSearcherQueue != null)
				{
					foreach (DirectorySearcher directorySearcher1 in aDDNLinkedAttrSetBookmark.memberSearcherQueue)
					{
						this.memberSearchersQueue.Enqueue(directorySearcher1);
					}
				}
			}
		}
Exemplo n.º 34
0
        private void DoLDAPDirectoryInitNoContainer()
        {
            string str  = null;
            string str1 = null;

            byte[]         numArray        = new byte[] { 169, 209, 202, 21, 118, 136, 17, 209, 173, 237, 0, 192, 79, 216, 213, 205 };
            byte[]         numArray1       = numArray;
            byte[]         numArray2       = new byte[] { 170, 49, 40, 37, 118, 136, 17, 209, 173, 237, 0, 192, 79, 216, 213, 205 };
            byte[]         numArray3       = numArray2;
            DirectoryEntry directoryEntry  = null;
            DirectoryEntry directoryEntry1 = null;
            DirectoryEntry directoryEntry2 = null;
            ADStoreCtx     aDStoreCtx      = null;
            ADStoreCtx     aDStoreCtx1     = null;
            ADStoreCtx     aDStoreCtx2     = null;
            DirectoryEntry directoryEntry3 = null;
            string         str2            = "";

            if (this.name != null)
            {
                str2 = string.Concat(this.name, "/");
            }
            AuthenticationTypes authTypes = SDSUtils.MapOptionsToAuthTypes(this.options);

            using (directoryEntry3)
            {
                directoryEntry3 = new DirectoryEntry(string.Concat("LDAP://", str2, "rootDse"), this.username, this.password, authTypes);
                string item = (string)directoryEntry3.Properties["defaultNamingContext"][0];
                str = string.Concat("LDAP://", str2, item);
            }
            try
            {
                directoryEntry2 = new DirectoryEntry(str, this.username, this.password, authTypes);
                if (this.serverProperties.portSSL > 0)
                {
                    directoryEntry2.Options.PasswordPort = this.serverProperties.portSSL;
                }
                string str3 = null;
                PropertyValueCollection propertyValueCollection = directoryEntry2.Properties["wellKnownObjects"];
                foreach (UnsafeNativeMethods.IADsDNWithBinary aDsDNWithBinary in propertyValueCollection)
                {
                    if (Utils.AreBytesEqual(numArray1, (byte[])aDsDNWithBinary.BinaryValue))
                    {
                        str3 = string.Concat("LDAP://", str2, aDsDNWithBinary.DNString);
                    }
                    if (!Utils.AreBytesEqual(numArray3, (byte[])aDsDNWithBinary.BinaryValue))
                    {
                        continue;
                    }
                    str1 = string.Concat("LDAP://", str2, aDsDNWithBinary.DNString);
                }
                if (str3 == null || str1 == null)
                {
                    throw new PrincipalOperationException(StringResources.ContextNoWellKnownObjects);
                }
                else
                {
                    directoryEntry  = new DirectoryEntry(str3, this.username, this.password, authTypes);
                    directoryEntry1 = new DirectoryEntry(str1, this.username, this.password, authTypes);
                    StoreCtx storeCtx = this.CreateContextFromDirectoryEntry(directoryEntry);
                    this.userCtx         = storeCtx;
                    this.groupCtx        = storeCtx;
                    directoryEntry       = null;
                    this.computerCtx     = this.CreateContextFromDirectoryEntry(directoryEntry1);
                    directoryEntry1      = null;
                    this.queryCtx        = this.CreateContextFromDirectoryEntry(directoryEntry2);
                    this.connectedServer = ADUtils.GetServerName(directoryEntry2);
                    directoryEntry2      = null;
                }
            }
            catch (Exception exception)
            {
                if (directoryEntry != null)
                {
                    directoryEntry.Dispose();
                }
                if (directoryEntry1 != null)
                {
                    directoryEntry1.Dispose();
                }
                if (directoryEntry2 != null)
                {
                    directoryEntry2.Dispose();
                }
                if (aDStoreCtx != null)
                {
                    aDStoreCtx.Dispose();
                }
                if (aDStoreCtx1 != null)
                {
                    aDStoreCtx1.Dispose();
                }
                if (aDStoreCtx2 != null)
                {
                    aDStoreCtx2.Dispose();
                }
                throw;
            }
        }
Exemplo n.º 35
0
		internal override void Reset()
		{
			if (!this.atBeginning)
			{
				this.usersVisited.Clear();
				this.groupsToVisit.Clear();
				string item = this.groupsVisited[0];
				this.groupsVisited.Clear();
				this.groupsVisited.Add(item);
				this.members = null;
				this.membersEnum = null;
				if (this.originalMembers != null)
				{
					this.membersQueue.Clear();
					foreach (IEnumerable enumerable in enumerable)
					{
						this.membersQueue.Enqueue(enumerable);
						IEnumerator enumerator = enumerable.GetEnumerator();
						enumerator.Reset();
					}
				}
				this.expansionMode = this.originalExpansionMode;
				this.storeCtx = this.originalStoreCtx;
				this.current = null;
				if (this.primaryGroupDN != null)
				{
					this.returnedPrimaryGroup = false;
				}
				this.foreignMembersCurrentGroup.Clear();
				this.fakePrincipalMembers.Clear();
				if (this.foreignMembersToReturn != null)
				{
					this.foreignMembersToReturn.Clear();
				}
				this.currentForeignPrincipal = null;
				this.currentForeignDE = null;
				this.foreignGroups.Clear();
				this.queryMembersResultEnumerator = null;
				if (this.queryMembersResults != null)
				{
					this.queryMembersResults.Dispose();
					this.queryMembersResults = null;
				}
				if (this.currentMembersSearcher != null)
				{
					this.currentMembersSearcher.Dispose();
					this.currentMembersSearcher = null;
				}
				this.memberSearchResultsEnumerator = null;
				if (this.memberSearchResults != null)
				{
					this.memberSearchResults.Dispose();
					this.memberSearchResults = null;
				}
				if (this.memberSearchersQueue != null)
				{
					foreach (DirectorySearcher directorySearcher in this.memberSearchersQueue)
					{
						directorySearcher.Dispose();
					}
					this.memberSearchersQueue.Clear();
					if (this.memberSearchersQueueOriginal != null)
					{
						foreach (DirectorySearcher directorySearcher1 in this.memberSearchersQueueOriginal)
						{
							this.memberSearchersQueue.Enqueue(directorySearcher1);
						}
					}
				}
				this.atBeginning = true;
			}
		}
Exemplo n.º 36
0
		private StoreCtx CreateContextFromDirectoryEntry(DirectoryEntry entry)
		{
			StoreCtx sAMStoreCtx;
			if (!entry.Path.StartsWith("LDAP:", StringComparison.Ordinal))
			{
				sAMStoreCtx = new SAMStoreCtx(entry, true, this.username, this.password, this.options);
			}
			else
			{
				if (this.ContextType != ContextType.ApplicationDirectory)
				{
					sAMStoreCtx = new ADStoreCtx(entry, true, this.username, this.password, this.options);
				}
				else
				{
					sAMStoreCtx = new ADAMStoreCtx(entry, true, this.username, this.password, this.name, this.options);
				}
			}
			sAMStoreCtx.OwningContext = this;
			return sAMStoreCtx;
		}
Exemplo n.º 37
0
		private bool ExpandForeignGroupEnumerator()
		{
			GroupPrincipal item = this.foreignGroups[0];
			this.foreignGroups.RemoveAt(0);
			this.storeCtx = (ADStoreCtx)item.Context.QueryCtx;
			this.membersQueue.Enqueue(new RangeRetriever((DirectoryEntry)item.UnderlyingObject, "member", true));
			string value = (string)((DirectoryEntry)item.UnderlyingObject).Properties["distinguishedName"].Value;
			this.groupsVisited.Add(value);
			return true;
		}
Exemplo n.º 38
0
		internal ADEntriesSet(SearchResultCollection src, ADStoreCtx storeCtx)
		{
			this.searchResults = src;
			this.storeCtx = storeCtx;
			this.enumerator = src.GetEnumerator();
		}
Exemplo n.º 39
0
		internal ADDNLinkedAttrSet(string groupDN, DirectorySearcher[] membersSearcher, string primaryGroupDN, DirectorySearcher primaryGroupMembersSearcher, bool recursive, ADStoreCtx storeCtx)
		{
			this.pathLock = new object();
			this.usersVisited = new Dictionary<string, bool>();
			this.groupsVisited = new List<string>();
			this.groupsToVisit = new List<string>();
			this.membersQueue = new Queue<IEnumerable>();
			this.originalMembers = new Queue<IEnumerable>();
			this.atBeginning = true;
			this.foreignMembersCurrentGroup = new List<DirectoryEntry>();
			this.fakePrincipalMembers = new List<DirectoryEntry>();
			this.foreignGroups = new List<GroupPrincipal>();
			this.memberSearchersQueue = new Queue<DirectorySearcher>();
			this.memberSearchersQueueOriginal = new Queue<DirectorySearcher>();
			this.groupsVisited.Add(groupDN);
			this.recursive = recursive;
			this.storeCtx = storeCtx;
			this.originalStoreCtx = storeCtx;
			this.members = null;
			this.originalMembers = null;
			this.membersEnum = null;
			this.primaryGroupDN = primaryGroupDN;
			if (primaryGroupDN == null)
			{
				this.returnedPrimaryGroup = true;
			}
			if (membersSearcher != null)
			{
				DirectorySearcher[] directorySearcherArray = membersSearcher;
				for (int i = 0; i < (int)directorySearcherArray.Length; i++)
				{
					DirectorySearcher directorySearcher = directorySearcherArray[i];
					this.memberSearchersQueue.Enqueue(directorySearcher);
					this.memberSearchersQueueOriginal.Enqueue(directorySearcher);
				}
			}
			this.currentMembersSearcher = null;
			this.primaryGroupMembersSearcher = primaryGroupMembersSearcher;
			this.expansionMode = ExpansionMode.ASQ;
			this.originalExpansionMode = this.expansionMode;
		}
Exemplo n.º 40
0
 static internal Principal SearchResultAsPrincipal(SearchResult sr, ADStoreCtx storeCtx, object discriminant)
 {
     if (ADUtils.IsOfObjectClass(sr, "computer") ||
        ADUtils.IsOfObjectClass(sr, "user") ||
        ADUtils.IsOfObjectClass(sr, "group"))
     {
         return storeCtx.GetAsPrincipal(sr, discriminant);
     }
     else if (ADUtils.IsOfObjectClass(sr, "foreignSecurityPrincipal"))
     {
         return storeCtx.ResolveCrossStoreRefToPrincipal(sr.GetDirectoryEntry());
     }
     else
     {
         return storeCtx.GetAsPrincipal(sr, discriminant);
     }
 }