Debian Codegraph @

test/support/windows-integration/plugins/modules/win_whoami.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Copyright: (c) 2017, Ansible Project
5 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 # this is a windows documentation stub. actual code lives in the .ps1
8 # file of the same name
9
10 ANSIBLE_METADATA = {'metadata_version': '1.1',
11 'status': ['preview'],
12 'supported_by': 'community'}
13
14 DOCUMENTATION = r"""
15 ---
16 module: win_whoami
17 version_added: "2.5"
18 short_description: Get information about the current user and process
19 description:
20 - Designed to return the same information as the C(whoami /all) command.
21 - Also includes information missing from C(whoami) such as logon metadata like
22 logon rights, id, type.
23 notes:
24 - If running this module with a non admin user, the logon rights will be an
25 empty list as Administrator rights are required to query LSA for the
26 information.
27 seealso:
28 - module: win_credential
29 - module: win_group_membership
30 - module: win_user_right
31 author:
32 - Jordan Borean (@jborean93)
33 """
34
35 EXAMPLES = r"""
36 - name: Get whoami information
37 win_whoami:
38 """
39
40 RETURN = r"""
41 authentication_package:
42 description: The name of the authentication package used to authenticate the
43 user in the session.
44 returned: success
45 type: str
46 sample: Negotiate
47 user_flags:
48 description: The user flags for the logon session, see UserFlags in
49 U(https://msdn.microsoft.com/en-us/library/windows/desktop/aa380128).
50 returned: success
51 type: str
52 sample: Winlogon
53 upn:
54 description: The user principal name of the current user.
55 returned: success
56 type: str
57 sample: [email protected]
58 logon_type:
59 description: The logon type that identifies the logon method, see
60 U(https://msdn.microsoft.com/en-us/library/windows/desktop/aa380129.aspx).
61 returned: success
62 type: str
63 sample: Network
64 privileges:
65 description: A dictionary of privileges and their state on the logon token.
66 returned: success
67 type: dict
68 sample: {
69 "SeChangeNotifyPrivileges": "enabled-by-default",
70 "SeRemoteShutdownPrivilege": "disabled",
71 "SeDebugPrivilege": "enabled"
72 }
73 label:
74 description: The mandatory label set to the logon session.
75 returned: success
76 type: complex
77 contains:
78 domain_name:
79 description: The domain name of the label SID.
80 returned: success
81 type: str
82 sample: Mandatory Label
83 sid:
84 description: The SID in string form.
85 returned: success
86 type: str
87 sample: S-1-16-12288
88 account_name:
89 description: The account name of the label SID.
90 returned: success
91 type: str
92 sample: High Mandatory Level
93 type:
94 description: The type of SID.
95 returned: success
96 type: str
97 sample: Label
98 impersonation_level:
99 description: The impersonation level of the token, only valid if
100 C(token_type) is C(TokenImpersonation), see
101 U(https://msdn.microsoft.com/en-us/library/windows/desktop/aa379572.aspx).
102 returned: success
103 type: str
104 sample: SecurityAnonymous
105 login_time:
106 description: The logon time in ISO 8601 format
107 returned: success
108 type: str
109 sample: '2017-11-27T06:24:14.3321665+10:00'
110 groups:
111 description: A list of groups and attributes that the user is a member of.
112 returned: success
113 type: list
114 sample: [
115 {
116 "account_name": "Domain Users",
117 "domain_name": "DOMAIN",
118 "attributes": [
119 "Mandatory",
120 "Enabled by default",
121 "Enabled"
122 ],
123 "sid": "S-1-5-21-1654078763-769949647-2968445802-513",
124 "type": "Group"
125 },
126 {
127 "account_name": "Administrators",
128 "domain_name": "BUILTIN",
129 "attributes": [
130 "Mandatory",
131 "Enabled by default",
132 "Enabled",
133 "Owner"
134 ],
135 "sid": "S-1-5-32-544",
136 "type": "Alias"
137 }
138 ]
139 account:
140 description: The running account SID details.
141 returned: success
142 type: complex
143 contains:
144 domain_name:
145 description: The domain name of the account SID.
146 returned: success
147 type: str
148 sample: DOMAIN
149 sid:
150 description: The SID in string form.
151 returned: success
152 type: str
153 sample: S-1-5-21-1654078763-769949647-2968445802-500
154 account_name:
155 description: The account name of the account SID.
156 returned: success
157 type: str
158 sample: Administrator
159 type:
160 description: The type of SID.
161 returned: success
162 type: str
163 sample: User
164 login_domain:
165 description: The name of the domain used to authenticate the owner of the
166 session.
167 returned: success
168 type: str
169 sample: DOMAIN
170 rights:
171 description: A list of logon rights assigned to the logon.
172 returned: success and running user is a member of the local Administrators group
173 type: list
174 sample: [
175 "SeNetworkLogonRight",
176 "SeInteractiveLogonRight",
177 "SeBatchLogonRight",
178 "SeRemoteInteractiveLogonRight"
179 ]
180 logon_server:
181 description: The name of the server used to authenticate the owner of the
182 logon session.
183 returned: success
184 type: str
185 sample: DC01
186 logon_id:
187 description: The unique identifier of the logon session.
188 returned: success
189 type: int
190 sample: 20470143
191 dns_domain_name:
192 description: The DNS name of the logon session, this is an empty string if
193 this is not set.
194 returned: success
195 type: str
196 sample: DOMAIN.COM
197 token_type:
198 description: The token type to indicate whether it is a primary or
199 impersonation token.
200 returned: success
201 type: str
202 sample: TokenPrimary
203 """