Browse Source

Send password to azure

Simon Fonteneau 2 months ago
parent
commit
1723db558b
3 changed files with 54 additions and 0 deletions
  1. 7
    0
      README.md
  2. 4
    0
      azure.conf
  3. 43
    0
      send_password_azure.py

+ 7
- 0
README.md View File

@@ -1 +1,8 @@
1
+Installation
2
+========================
1 3
 
4
+Please configure azure.conf
5
+For use with : https://github.com/sfonteneau/samba4-sync-password
6
+
7
+Installation azure sdk:
8
+https://github.com/lee212/simpleazure/blob/master/docs/arm.rst

+ 4
- 0
azure.conf View File

@@ -0,0 +1,4 @@
1
+[common]
2
+mailadmin = exemple@domain.com
3
+passwordadmin = password
4
+tenantid = abcd123456

+ 43
- 0
send_password_azure.py View File

@@ -0,0 +1,43 @@
1
+#!/usr/bin/python
2
+import sys 
3
+from azure.common.credentials import UserPassCredentials
4
+from azure.graphrbac import GraphRbacManagementClient
5
+from azure.graphrbac.models import PasswordProfile, UserUpdateParameters
6
+from ConfigParser import SafeConfigParser
7
+
8
+login = sys.argv[1]
9
+newpassword = sys.argv[2].decode('base64')
10
+try:
11
+    mail = sys.argv[3]
12
+except:
13
+    mail = ''
14
+
15
+## Get confgiruation
16
+config = SafeConfigParser()
17
+config.read('azure.conf')
18
+
19
+mailadmin = config.get('common', 'mailadmin')
20
+passwordadmin = config.get('common', 'passwordadmin')
21
+tenantid = config.get('common', 'tenantid')
22
+
23
+def main():
24
+
25
+    credentials = UserPassCredentials(
26
+    mailadmin, passwordadmin, resource="https://graph.windows.net"
27
+    )
28
+
29
+    graphrbac_client = GraphRbacManagementClient(
30
+       credentials,
31
+       tenantid
32
+    )
33
+
34
+    param = UserUpdateParameters(
35
+                    password_profile=PasswordProfile(
36
+                    password=newpassword,
37
+                    force_change_password_next_login=False
38
+                    )
39
+            )
40
+
41
+    user = graphrbac_client.users.update(mail, param)
42
+
43
+main()

Loading…
Cancel
Save