Exemplo n.º 1
0
def getGC():
    cont = adsi.ADsOpenObject("GC:", options.user, options.password, 0, adsi.IID_IADsContainer)
    enum = adsi.ADsBuildEnumerator(cont)
    # Only 1 child of the global catalog.
    for e in enum:
        gc = e.QueryInterface(adsi.IID_IDirectorySearch)
        return gc
    return None
Exemplo n.º 2
0
    def __iter__(self):
        #
        # Try raise a meaningful error if you can't get an enumerator,
        # although it appears that you can enumerate just about anything,
        # including an IADsUser! It just returns an empty list.
        #
        try:
            enumerator = adsi.ADsBuildEnumerator(
                self._obj.QueryInterface(adsi.IID_IADsContainer))
        except:
            raise TypeError("%r is not iterable" % self)

        while True:
            item = adsi.ADsEnumerateNext(enumerator, 1)
            if item:
                yield IADs.from_object(item[0])
            else:
                break