Connecting to Groupshare Server in the Code + Active Directory Authentication

Dears , 


I'm working on  a plugin that connects to the groupshare DB and gets all open projects and import them to the Project controller  ..

In the code , I define the server as :

 
Uri serverAddress = new Uri("ps.MyServerAddress:MyPort/");
server = new ProjectServer(serverAddress, false, "MyUserName", "MyPassword");

 

I connect to the DB and place the results in datatable , later I loop throght the result table and create local copy and Open the project as in below :

for (int i = 0; i < dtable.Rows.Count; i++)
{
string[] arr = new string[5];

DataRow drow = dtable.Rows[i];

string MyPath = @"c:\MyImports\" + drow["resourceName"];

// Only row that have not been deleted
if (drow.RowState != DataRowState.Deleted)
{
if (Directory.Exists(Path))
{


}


else
{
DirectoryInfo di = Directory.CreateDirectory(Path);
Guid IDGuid = new Guid(drow["resourceGuid"].ToString());
FileBasedProject project = server.OpenProject(IDGuid, MyPath);

}
}


Now the issue is since I'm using the credentials in my Code ' declaring the server server = new ProjectServer(serverAddress, false, "MyUserName", "MyPassword");
If the user is using  his SDL username ex : ' user1'  and he clcik on the import plugin , His logged in account will be switched to the one I use in Code , 'MyUsername'

 

My questions are  :


 - How can I logout from the username I'm using in th code once I'm done ? 
 - Also I'm thinking if we can switch to use the Active Directory Authentication instead of the SDL Authentication  , this might fix the issue  and no nee to write the useranme and password in teh code , is there any documentation on how to apply it ?

 

Thank you in advanse ..

Parents Reply Children
No Data