<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.0.4630.0">
<TITLE>LsaAddAccountRights help</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Arial">Hello,</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">I'm trying to give a user a "Log on as a Service" right using the Python Win32 modules. Here is the code in question:</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">#!/usr/bin/env python</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">import win32security</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">username = "Administrator"</FONT>
<BR><FONT SIZE=2 FACE="Arial">system_name = "temp_system"</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">policy_handle = win32security.LsaOpenPolicy(system_name, win32security.POLICY_ALL_ACCESS)</FONT>
<BR><FONT SIZE=2 FACE="Arial">sid_obj, domain, tmp = win32security.LookupAccountName(system_name, username)</FONT>
<BR><FONT SIZE=2 FACE="Arial">win32security.LsaAddAccountRights( policy_handle, sid_obj, win32security.SE_SERVICE )</FONT>
<BR><FONT SIZE=2 FACE="Arial">win32security.LsaClose( policy_handle )</FONT>
</P>
<BR>
<P><FONT SIZE=2 FACE="Arial">I'm running this code as Administrator, so having the proper permissions to perform this operation shouldn't be a question. Here is what I'm getting when I run the above code:</FONT></P>
<P><FONT SIZE=2 FACE="Arial">Traceback (most recent call last):</FONT>
<BR><FONT SIZE=2 FACE="Arial"> File "C:\example.py", line 12, in ?</FONT>
<BR><FONT SIZE=2 FACE="Arial"> win32security.LsaAddAccountRights( policy_handle, sid_obj, win32security.SE_SERVICE )</FONT>
<BR><FONT SIZE=2 FACE="Arial">SystemError: error return without exception set</FONT>
</P>
<BR>
<P><FONT SIZE=2 FACE="Arial">I'm cluess as to what is going on. Any help is appreciated. By the way, I'm using Python 2.3.3 with PythonWin32 build 202.</FONT></P>
<BR>
<P><FONT SIZE=2 FACE="Arial">Thanks,</FONT>
<BR><FONT SIZE=2 FACE="Arial">Gus</FONT>
</P>
</BODY>
</HTML>