class 'pywintypes.com_error'>: (-2147352567, 'Ausnahmefehler aufgetreten.', (0, u'Provider', u'Klasse nicht registriert'

Python in C/C++ embedden, C-Module, ctypes, Cython, SWIG, SIP etc sind hier richtig.
kleiner_syrer
User
Beiträge: 5
Registriert: Mittwoch 18. Januar 2017, 20:44

class 'pywintypes.com_error'>: (-2147352567, 'Ausnahmefehler aufgetreten.', (0, u'Provider', u'Klasse nicht registriert'

Beitragvon kleiner_syrer » Mittwoch 18. Januar 2017, 21:05

Hallo,

erhalte wenn ich ein Pythonskript über ein Webformular als CGI anspreche folgende Fehlermeldung:

class 'pywintypes.com_error'>: (-2147352567, 'Ausnahmefehler aufgetreten.', (0, u'Provider', u'Klasse nicht registriert', None, 1240640, -2147221164), None)

Möglicherweise hat Python ein Problem mit der folgenden Zeile:

user = active_directory.find_user (form.getfirst('uid',""))

auch in abgewandelter Form funktioniert es nicht:

user = active_directory.find_user (form.getvalue('uid'))

Das Module active_directory funktioniert ohne Probleme.

Der Webserver ist ein Apache (in XAMPP) // XAMPP for Windows 7.0.13 // Windows 10 64 Bit // Python2.7 32 Bit/

Danke für die Unterstützung


Hier das Skript:

  1. #!C:\Temp\Python27\python.exe
  2. #-*- coding: utf-8 -*-
  3.  
  4. from __future__ import print_function
  5. import httplib2
  6. import json
  7. import os
  8. import sys
  9. sys.path.append('C:\Temp\Python27\0.6.7')
  10. import active_directory
  11.  
  12. import cgi, cgitb
  13. cgitb.enable()
  14.  
  15. form = cgi.FieldStorage()
  16. s1=form.getfirst('uid',"")
  17. s2=form.getvalue('passwort')
  18. user = active_directory.find_user (form.getfirst('uid',""))
  19.  
  20. #KTT apiclient change into googleapiclient'''
  21. from googleapiclient import discovery
  22. from oauth2client import client
  23. from oauth2client import tools
  24. from oauth2client.file import Storage
  25. from json import loads, dumps
  26.  
  27.  
  28.  
  29. # If modifying these scopes, delete your previously saved credentials
  30. # at ~/.credentials/admin-directory_v1-python-quickstart.json
  31. SCOPES = 'https://www.googleapis.com/auth/admin.directory.user'
  32. CLIENT_SECRET_FILE = 'client_secret.json'
  33. APPLICATION_NAME = 'Directory API Python Quickstart'
  34.  
  35.  
  36.  
  37. def get_credentials():
  38.     """Gets valid user credentials from storage.
  39.  
  40.    If nothing has been stored, or if the stored credentials are invalid,
  41.    the OAuth2 flow is completed to obtain the new credentials.
  42.  
  43.    Returns:
  44.        Credentials, the obtained credential.
  45.    """
  46.     home_dir = os.path.expanduser('~')
  47.     credential_dir = os.path.join(home_dir, '.credentials')
  48.     if not os.path.exists(credential_dir):
  49.         os.makedirs(credential_dir)
  50.     credential_path = os.path.join(credential_dir,
  51.                                    'admin-directory_v1-python-quickstart.json')
  52.  
  53.     store = Storage(credential_path)
  54.     credentials = store.get()
  55.     if not credentials or credentials.invalid:
  56.         flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES)
  57.         flow.user_agent = APPLICATION_NAME
  58.         if flags:
  59.             credentials = tools.run_flow(flow, store, flags)
  60.         else: # Needed only for compatibility with Python 2.6
  61.             credentials = tools.run(flow, store)
  62.         print('Storing credentials to ' + credential_path)
  63.     return credentials
  64.  
  65.  
  66. def main():
  67.     credentials = get_credentials()
  68.         http = credentials.authorize(httplib2.Http())
  69.         service = discovery.build('admin', 'directory_v1', http=http)
  70.         content = http.request(
  71.                                uri='https://www.googleapis.com/admin/directory/v1/users',
  72.                                method='POST',
  73.                                headers={'Content-Type': 'application/json; charset=UTF-8'},
  74.                                body=dumps({"kind": "admin#directory#user",
  75.                                            "password": s2,
  76.                                            "changePasswordAtNextLogin": True,
  77.                                            "orgUnitPath": '''/''' + user.userPrincipalName.split("@",1)[-1],
  78.                                            "primaryEmail": user.userPrincipalName,
  79.                                            "customerID": "my_customer",
  80.                                            "name": {"givenName": user.givenName, "familyName": user.sn}
  81.                                           })
  82.                                        )
  83.         print (content)
  84. if __name__ == '__main__':
  85.     main();


HIer die ´Fehlermeldung aus dem Browser:

<class 'pywintypes.com_error'> Python 2.7.13: C:\Temp\Python27\python.exe
Wed Jan 18 20:28:50 2017

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.

C:\Temp\xampp\cgi-bin\cgi_formular_auswertung.cgi in ()
16 s1=form.getfirst('uid',"")

17 s2=form.getvalue('passwort')

=> 18 user = active_directory.find_user (form.getfirst('uid',""))

19

20 #KTT apiclient change into googleapiclient'''

user undefined, active_directory = <module 'active_directory' from 'C:\Temp\xampp\cgi-bin\active_directory.pyc'>, active_directory.find_user = <function find_user>, form = FieldStorage(None, None, [MiniFieldStorage('uid'...MiniFieldStorage('submit', 'Account erstellen')]), form.getfirst = <bound method FieldStorage.getfirst of FieldStor...iniFieldStorage('submit', 'Account erstellen')])>

C:\Temp\xampp\cgi-bin\active_directory.py in find_user(name='DEJHFK10')
720

721 def find_user (name=None):

=> 722 return root ().find_user (name)

723

724 def find_computer (name=None):

global root = <function root>, ).find_user undefined, name = 'DEJHFK10'

C:\Temp\xampp\cgi-bin\active_directory.py in find_user(self=<_AD_domain_dns: LDAP://DC=business,DC=jungheinrich,DC=com>, name='DEJHFK10')
538 def find_user (self, name=None):

539 name = name or win32api.GetUserName ()

=> 540 for user in self.search ("sAMAccountName='%s' OR displayName='%s' OR cn='%s'" % (name, name, name), objectCategory='Person', objectClass='User'):

541 return user

542

user undefined, self = <_AD_domain_dns: LDAP://DC=business,DC=jungheinrich,DC=com>, self.search = <bound method _AD_domain_dns.search of <_AD_domain_dns: LDAP://DC=business,DC=jungheinrich,DC=com>>, name = 'DEJHFK10', objectCategory undefined, objectClass undefined

C:\Temp\xampp\cgi-bin\active_directory.py in search(self=<_AD_domain_dns: LDAP://DC=business,DC=jungheinrich,DC=com>, *args=("sAMAccountName='DEJHFK10' OR displayName='DEJHFK10' OR cn='DEJHFK10'",), **kwargs={'objectCategory': 'Person', 'objectClass': 'User'})
571 sql_string.append ("WHERE %s" % where_clause)

572

=> 573 for result in query ("\n".join (sql_string), Page_size=50):

574 yield AD_object (result.ADsPath.Value)

575

result undefined, global query = <function query>, "\n".join undefined, sql_string = ['SELECT *', u"FROM 'LDAP://DC=business,DC=jungheinrich,DC=com'", "WHERE sAMAccountName='DEJHFK10' OR displayName='...ND objectClass='User' AND objectCategory='Person'"], Page_size undefined

C:\Temp\xampp\cgi-bin\active_directory.py in query(query_string=u"SELECT *\nFROM 'LDAP://DC=business,DC=jungheinric...ND objectClass='User' AND objectCategory='Person'", **command_properties={'Page_size': 50})
308 command.CommandText = query_string

309

=> 310 recordset, result = command.Execute ()

311 while not recordset.EOF:

312 yield ADO_record (recordset)

recordset undefined, result undefined, command = <COMObject ADODB.Command>, command.Execute = <bound method CDispatch.Execute of <COMObject ADODB.Command>>

C:\Temp\xampp\cgi-bin\<COMObject ADODB.Command> in Execute(self=<COMObject ADODB.Command>, RecordsAffected=<PyOleMissing object>, Parameters=<PyOleMissing object>, Options=-1)


C:\Temp\Python27\lib\site-packages\win32com\client\dynamic.py in _ApplyTypes_(self=<COMObject ADODB.Command>, dispid=5, wFlags=1, retType=(9, 0), argTypes=((16396, 18), (16396, 17), (3, 49)), user='Execute', resultCLSID='{00001556-0000-0010-8000-00AA006D2EA4}', *args=(<PyOleMissing object>, <PyOleMissing object>, -1))
285

286 def _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID, *args):

=> 287 result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes) + args)

288 return self._get_good_object_(result, user, resultCLSID)

289

result undefined, self = <COMObject ADODB.Command>, self._oleobj_ = <PyIDispatch at 0x03049878 with obj>, self._oleobj_.InvokeTypes = <built-in method InvokeTypes of PyIDispatch object>, dispid = 5, global LCID = 0, wFlags = 1, retType = (9, 0), argTypes = ((16396, 18), (16396, 17), (3, 49)), args = (<PyOleMissing object>, <PyOleMissing object>, -1)

<class 'pywintypes.com_error'>: (-2147352567, 'Ausnahmefehler aufgetreten.', (0, u'Provider', u'Klasse nicht registriert', None, 1240640, -2147221164), None)
argerror = None
args = (-2147352567, 'Ausnahmefehler aufgetreten.', (0, u'Provider', u'Klasse nicht registriert', None, 1240640, -2147221164), None)
excepinfo = (0, u'Provider', u'Klasse nicht registriert', None, 1240640, -2147221164)
hresult = -2147352567
message = ''
strerror = 'Ausnahmefehler aufgetreten.'
Zuletzt geändert von Anonymous am Mittwoch 18. Januar 2017, 23:00, insgesamt 1-mal geändert.
Grund: Quelltext in Python-Codebox-Tags gesetzt.

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder