Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
nmasGetUniversalPassword.py57 linesDownload Raw Back to novell
1"""
2"""
3
4# Created on 2014.07.03
5#
6# Author: Giovanni Cannata
7#
8# Copyright 2014 - 2020 Giovanni Cannata
9#
10# This file is part of ldap3.
11#
12# ldap3 is free software: you can redistribute it and/or modify
13# it under the terms of the GNU Lesser General Public License as published
14# by the Free Software Foundation, either version 3 of the License, or
15# (at your option) any later version.
16#
17# ldap3 is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20# GNU Lesser General Public License for more details.
21#
22# You should have received a copy of the GNU Lesser General Public License
23# along with ldap3 in the COPYING and COPYING.LESSER files.
24# If not, see <http://www.gnu.org/licenses/>.
25
26from ...extend.operation import ExtendedOperation
27from ...protocol.novell import NmasGetUniversalPasswordRequestValue, NmasGetUniversalPasswordResponseValue, NMAS_LDAP_EXT_VERSION
28from ...utils.dn import safe_dn
29
30
31class NmasGetUniversalPassword(ExtendedOperation):
32    def config(self):
33        self.request_name = '2.16.840.1.113719.1.39.42.100.13'
34        self.response_name = '2.16.840.1.113719.1.39.42.100.14'
35        self.request_value = NmasGetUniversalPasswordRequestValue()
36        self.asn1_spec = NmasGetUniversalPasswordResponseValue()
37        self.response_attribute = 'password'
38
39    def __init__(self, connection, user, controls=None):
40        ExtendedOperation.__init__(self, connection, controls)  # calls super __init__()
41
42        if connection.check_names:
43            user = safe_dn(user)
44
45        self.request_value['nmasver'] = NMAS_LDAP_EXT_VERSION
46        self.request_value['reqdn'] = user
47
48    def populate_result(self):
49        if self.decoded_response:
50            self.result['nmasver'] = int(self.decoded_response['nmasver'])
51            self.result['error'] = int(self.decoded_response['err'])
52            try:
53
54                self.result['password'] = str(self.decoded_response['passwd']) if self.decoded_response['passwd'].hasValue() else None
55            except TypeError:
56                self.result['password'] = None
57 
codekingpro/portable-devtools · Team Ai