Created
March 21, 2011 19:11
-
-
Save felipe-prenholato/880015 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: from ldap_connector.models import LdapUser | |
In [2]: | |
In [3]: x = LdapUser.objects.filter(username__icontains='teste.ad') | |
In [4]: for u in x: | |
...: print u.full_name,u.username,u.email | |
...: | |
...: | |
teste.ad05 teste.ad05 [email protected] | |
teste.ad04 teste.ad04 [email protected] | |
teste.ad03 teste.ad03 [email protected] | |
teste.ad02 teste.ad02 [email protected] | |
teste.ad01 teste.ad01 [email protected] | |
In [5]: u | |
Out[5]: <LdapUser: teste.ad01 (teste.ad01)> | |
In [6]: u.__dict__ | |
Out[6]: | |
{'_state': <django.db.models.base.ModelState object at 0x1d638d0>, | |
'dn': u'CN=teste.ad01,OU=Users,OU=Informatica,OU=Filial,OU=Goldfarb,DC=goldfarb,DC=corp', | |
'email': u'[email protected]', | |
'first_name': u'teste.ad01', | |
'full_name': u'teste.ad01', | |
'id': None, | |
'last_name': '', | |
'model_ptr_id': None, | |
'saved_pk': None, | |
'username': u'teste.ad01'} | |
In [7]: u | |
Out[7]: <LdapUser: teste.ad01 (teste.ad01)> | |
In [8]: u.first_name | |
Out[8]: u'teste.ad01' | |
In [9]: u.first_name = 'Teste User' | |
In [10]: u.last_name = 'AD 01' | |
In [11]: u.save() | |
--------------------------------------------------------------------------- | |
FILTER_ERROR Traceback (most recent call last) | |
/home/felipe/projects/portal/portal/<ipython console> in <module>() | |
/home/felipe/projects/portal/lib/python2.6/site-packages/ldapdb/models/base.pyc in save(self) | |
133 record_exists = True | |
134 modlist = [] | |
--> 135 orig = self.__class__.objects.get(pk=self.saved_pk) | |
136 for field in self._meta.fields: | |
137 if not field.db_column: | |
/home/felipe/projects/portal/lib/python2.6/site-packages/django/db/models/manager.pyc in get(self, *args, **kwargs) | |
130 | |
131 def get(self, *args, **kwargs): | |
--> 132 return self.get_query_set().get(*args, **kwargs) | |
133 | |
134 def get_or_create(self, **kwargs): | |
/home/felipe/projects/portal/lib/python2.6/site-packages/django/db/models/query.pyc in get(self, *args, **kwargs) | |
334 if self.query.can_filter(): | |
335 clone = clone.order_by() | |
--> 336 num = len(clone) | |
337 if num == 1: | |
338 return clone._result_cache[0] | |
/home/felipe/projects/portal/lib/python2.6/site-packages/django/db/models/query.pyc in __len__(self) | |
79 self._result_cache = list(self._iter) | |
80 else: | |
---> 81 self._result_cache = list(self.iterator()) | |
82 elif self._iter: | |
83 self._result_cache.extend(list(self._iter)) | |
/home/felipe/projects/portal/lib/python2.6/site-packages/django/db/models/query.pyc in iterator(self) | |
267 | |
268 compiler = self.query.get_compiler(using=self.db) | |
--> 269 for row in compiler.results_iter(): | |
270 if fill_cache: | |
271 obj, _ = get_cached_row(self.model, row, | |
/home/felipe/projects/portal/lib/python2.6/site-packages/ldapdb/models/query.pyc in results_iter(self) | |
97 self.query.model.search_scope, | |
98 filterstr=self.query._ldap_filter(), | |
---> 99 attrlist=attrlist, | |
100 ) | |
101 except ldap.NO_SUCH_OBJECT: | |
/home/felipe/projects/portal/lib/python2.6/site-packages/ldapdb/__init__.pyc in search_s(self, base, scope, filterstr, attrlist) | |
91 cursor = self._cursor() | |
92 output = [] | |
---> 93 search = cursor.connection.search(base, scope, filterstr.encode(self.charset), attrlist) | |
94 if type(search) is int: | |
95 while True: | |
/home/felipe/projects/portal/lib/python2.6/site-packages/ldap/ldapobject.pyc in search(self, base, scope, filterstr, attrlist, attrsonly) | |
497 | |
498 def search(self,base,scope,filterstr='(objectClass=*)',attrlist=None,attrsonly=0): | |
--> 499 return self.search_ext(base,scope,filterstr,attrlist,attrsonly,None,None) | |
500 | |
501 def search_s(self,base,scope,filterstr='(objectClass=*)',attrlist=None,attrsonly=0): | |
/home/felipe/projects/portal/lib/python2.6/site-packages/ldap/ldapobject.pyc in search_ext(self, base, scope, filterstr, attrlist, attrsonly, serverctrls, clientctrls, timeout, sizelimit) | |
489 EncodeControlTuples(serverctrls), | |
490 EncodeControlTuples(clientctrls), | |
--> 491 timeout,sizelimit, | |
492 ) | |
493 | |
/home/felipe/projects/portal/lib/python2.6/site-packages/ldap/ldapobject.pyc in _ldap_call(self, func, *args, **kwargs) | |
94 try: | |
95 try: | |
---> 96 result = func(*args,**kwargs) | |
97 if __debug__ and self._trace_level>=2: | |
98 if func.__name__!="unbind_ext": | |
FILTER_ERROR: {'desc': 'Bad search filter'} | |
In [12]: | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment