OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cloud_print/service/win/local_security_policy.h" | 5 #include "cloud_print/service/win/local_security_policy.h" |
6 | 6 |
7 #include <atlsecurity.h> | 7 #include <atlsecurity.h> |
8 #include <ntsecapi.h> | 8 #include <ntsecapi.h> |
9 #include <windows.h> | 9 #include <windows.h> |
10 | 10 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 const base::string16& privilage) { | 102 const base::string16& privilage) { |
103 DCHECK(policy_); | 103 DCHECK(policy_); |
104 ATL::CSid user_sid; | 104 ATL::CSid user_sid; |
105 if (!user_sid.LoadAccount(username.c_str())) { | 105 if (!user_sid.LoadAccount(username.c_str())) { |
106 LOG(ERROR) << "Unable to load Sid for" << username; | 106 LOG(ERROR) << "Unable to load Sid for" << username; |
107 return false; | 107 return false; |
108 } | 108 } |
109 LSA_UNICODE_STRING privilege_string; | 109 LSA_UNICODE_STRING privilege_string; |
110 base::string16 privilage_copy(privilage); | 110 base::string16 privilage_copy(privilage); |
111 privilege_string.Buffer = &privilage_copy[0]; | 111 privilege_string.Buffer = &privilage_copy[0]; |
112 privilege_string.Length = static_cast<USHORT>( | 112 privilege_string.Length = wcslen(privilege_string.Buffer) * |
113 wcslen(privilege_string.Buffer) * sizeof(privilege_string.Buffer[0])); | 113 sizeof(privilege_string.Buffer[0]); |
114 privilege_string.MaximumLength = privilege_string.Length + | 114 privilege_string.MaximumLength = privilege_string.Length + |
115 sizeof(privilege_string.Buffer[0]); | 115 sizeof(privilege_string.Buffer[0]); |
116 return STATUS_SUCCESS == | 116 return STATUS_SUCCESS == |
117 ::LsaAddAccountRights(policy_, const_cast<SID*>(user_sid.GetPSID()), | 117 ::LsaAddAccountRights(policy_, const_cast<SID*>(user_sid.GetPSID()), |
118 &privilege_string, 1); | 118 &privilege_string, 1); |
119 } | 119 } |
120 | 120 |
OLD | NEW |