Logging onto PS2007 using specific Windows account

A

asadim

Is it possible to instruct my C# app to logon to PS2007 using a Windows
authenticated account? Please note that I'd like to specify which account to
logon with (e.g. I want my app to run as the admin).

Thanks in advance.
 
A

asadim

So that's what impersonation is. Thanks.

I followed http://msdn2.microsoft.com/en-us/library/aa974413.aspx and
created a method called Impersonate(string userAccount) which is pretty much
the main() function in the article. It impersonates the user account fine but
it doesn't logon as the impersonated user. This is what I've got in my
LogonPS() function:

public static bool LogonPS(bool isWindowsUser, string userAccount,
string baseUrl)
{
// some code here

string currentUser;
currentUser =
System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();

if (currentUser != userAccount)
{
Impersonate(userAccount);
}

if (loginWindows.Login())
{
logonSucceeded = true;
}

// some code here
}

In Program.cs under main() I simply call LogonPS() with appropriate
parameters passed.

Please advise.
 
B

Boaz Lev [MSFT]

It is hard to tell what the problem is without having seen the code you are
actually executing (it could be something as simple as a typing mistake).
Have you validated that the user you are trying to impersonate actually
exists on the server? What user does the code actually try to log in as?

Thanks,
 
G

Gizmo Gizmo

Hi asadim,

you can find great directions in the Project Server SDK:

How to: Write a Simple Impersonation Application
Using the ProjTool Test Application

There are even some code sample applications shipped with the SDK that will
help you, they are in folders:
- Impersonation
- ProjTool

Good luck!
 
A

asadim

Boaz,

Sorry for the long delay. The code I am using to impersonate a user is
exactly taken from the SDK article (How to: Write a Simple Impersonation
Application). In my code in the LogonPS() function first I make a successful
call to the impersonator function, Impersonate(), and then do a
loginWindows.Login(). I am wondering if there're any other steps I need to
take in order to successfully logon as another user?

Maybe I should ask my question this way: What exactly does the impersonator
function do? When I do an impersonation of a user account, say UserX, can I
access Project Server with UserX's access rights/permissions?

My goal is to instruct my app to logon to PS as admin and carry out a series
of operations (that are already written). I thought if I do a Impersonate()
right before logging in would be enough, but I'm not sure about it.

Any advise is appreciated.

P.S> Throughout my posting, any references to an impersonation function or
Impersonate() refer to the exact same function in the SDK manual.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top