Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: cloud_print/service/win/local_security_policy.cc

Issue 107383002: Use base namespace for string16 in components and cloud_print. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 bool LocalSecurityPolicy::Open() { 69 bool LocalSecurityPolicy::Open() {
70 DCHECK(!policy_); 70 DCHECK(!policy_);
71 Close(); 71 Close();
72 LSA_OBJECT_ATTRIBUTES attributes = {0}; 72 LSA_OBJECT_ATTRIBUTES attributes = {0};
73 return STATUS_SUCCESS == 73 return STATUS_SUCCESS ==
74 ::LsaOpenPolicy(NULL, &attributes, 74 ::LsaOpenPolicy(NULL, &attributes,
75 POLICY_CREATE_ACCOUNT | POLICY_LOOKUP_NAMES, 75 POLICY_CREATE_ACCOUNT | POLICY_LOOKUP_NAMES,
76 &policy_); 76 &policy_);
77 } 77 }
78 78
79 bool LocalSecurityPolicy::IsPrivilegeSet(const string16& username, 79 bool LocalSecurityPolicy::IsPrivilegeSet(
80 const string16& privilage) const { 80 const base::string16& username,
81 const base::string16& privilage) const {
81 DCHECK(policy_); 82 DCHECK(policy_);
82 ATL::CSid user_sid; 83 ATL::CSid user_sid;
83 if (!user_sid.LoadAccount(username.c_str())) { 84 if (!user_sid.LoadAccount(username.c_str())) {
84 LOG(ERROR) << "Unable to load Sid for" << username; 85 LOG(ERROR) << "Unable to load Sid for" << username;
85 return false; 86 return false;
86 } 87 }
87 ScopedLsaMemory<LSA_UNICODE_STRING> rights; 88 ScopedLsaMemory<LSA_UNICODE_STRING> rights;
88 ULONG count = 0; 89 ULONG count = 0;
89 NTSTATUS status = ::LsaEnumerateAccountRights( 90 NTSTATUS status = ::LsaEnumerateAccountRights(
90 policy_, const_cast<SID*>(user_sid.GetPSID()), rights.Receive(), &count); 91 policy_, const_cast<SID*>(user_sid.GetPSID()), rights.Receive(), &count);
91 if (STATUS_SUCCESS != status || !rights.Get()) 92 if (STATUS_SUCCESS != status || !rights.Get())
92 return false; 93 return false;
93 for (size_t i = 0; i < count; ++i) { 94 for (size_t i = 0; i < count; ++i) {
94 if (privilage == rights.Get()[i].Buffer) 95 if (privilage == rights.Get()[i].Buffer)
95 return true; 96 return true;
96 } 97 }
97 return false; 98 return false;
98 } 99 }
99 100
100 bool LocalSecurityPolicy::SetPrivilege(const string16& username, 101 bool LocalSecurityPolicy::SetPrivilege(const base::string16& username,
101 const string16& privilage) { 102 const base::string16& privilage) {
102 DCHECK(policy_); 103 DCHECK(policy_);
103 ATL::CSid user_sid; 104 ATL::CSid user_sid;
104 if (!user_sid.LoadAccount(username.c_str())) { 105 if (!user_sid.LoadAccount(username.c_str())) {
105 LOG(ERROR) << "Unable to load Sid for" << username; 106 LOG(ERROR) << "Unable to load Sid for" << username;
106 return false; 107 return false;
107 } 108 }
108 LSA_UNICODE_STRING privilege_string; 109 LSA_UNICODE_STRING privilege_string;
109 string16 privilage_copy(privilage); 110 base::string16 privilage_copy(privilage);
110 privilege_string.Buffer = &privilage_copy[0]; 111 privilege_string.Buffer = &privilage_copy[0];
111 privilege_string.Length = wcslen(privilege_string.Buffer) * 112 privilege_string.Length = wcslen(privilege_string.Buffer) *
112 sizeof(privilege_string.Buffer[0]); 113 sizeof(privilege_string.Buffer[0]);
113 privilege_string.MaximumLength = privilege_string.Length + 114 privilege_string.MaximumLength = privilege_string.Length +
114 sizeof(privilege_string.Buffer[0]); 115 sizeof(privilege_string.Buffer[0]);
115 return STATUS_SUCCESS == 116 return STATUS_SUCCESS ==
116 ::LsaAddAccountRights(policy_, const_cast<SID*>(user_sid.GetPSID()), 117 ::LsaAddAccountRights(policy_, const_cast<SID*>(user_sid.GetPSID()),
117 &privilege_string, 1); 118 &privilege_string, 1);
118 } 119 }
119 120
OLDNEW
« no previous file with comments | « cloud_print/service/win/local_security_policy.h ('k') | cloud_print/service/win/service_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698