Esempio n. 1
0
 def setprimarygroup(self, user_dn, group_dn):
     res = self.lo.search_ext_s(group_dn, ldap.SCOPE_BASE, timeout=10)
     import re
     groupid = (re.search('^(.*)-(.*?)$',
                          ad.decode_sid(
                              res[0][1]['objectSid'][0]))).group(2)
     self.set_attribute(user_dn, 'primaryGroupID', groupid)
Esempio n. 2
0
    def getprimarygroup(self, user_dn):
        try:
            res = self.lo.search_ext_s(user_dn, ldap.SCOPE_BASE, timeout=10)
        except:
            return None
        primaryGroupID = res[0][1]['primaryGroupID'][0]
        res = self.lo.search_ext_s(self.adldapbase,
                                   ldap.SCOPE_SUBTREE,
                                   'objectClass=group'.encode('utf8'),
                                   timeout=10)

        import re
        regex = '^(.*?)-%s$' % primaryGroupID
        for r in res:
            if r[0] is None or r[0] == 'None':
                continue  # Referral
            if re.search(regex, ad.decode_sid(r[1]['objectSid'][0])):
                return r[0]
Esempio n. 3
0
	def getprimarygroup(self, user_dn):
		try:
			res = self.lo.search_ext_s(user_dn, ldap.SCOPE_BASE, timeout=10)
		except:
			return None
		primaryGroupID = res[0][1]['primaryGroupID'][0]
		res = self.lo.search_ext_s(self.adldapbase,
								   ldap.SCOPE_SUBTREE,
								   'objectClass=group'.encode ('utf8'),
								   timeout=10)

		import re
		regex = '^(.*?)-%s$' % primaryGroupID
		for r in res:
			if r[0] == None or r[0] == 'None':
				continue # Referral
			if re.search (regex, ad.decode_sid(r[1]['objectSid'][0])):
				return r[0]
Esempio n. 4
0
	def setprimarygroup(self, user_dn, group_dn):
		res = self.lo.search_ext_s(group_dn, ldap.SCOPE_BASE, timeout=10)
		import re
		groupid = (re.search ('^(.*)-(.*?)$', ad.decode_sid (res[0][1]['objectSid'][0]))).group (2)
		self.set_attribute (user_dn, 'primaryGroupID', groupid)