Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
Highlighted
Matt Bayliss Honored Contributor.
Honored Contributor.
117 views

.Net SDK using SetAuthenticationCredentials with ADFS

Jump to solution

Say I have code like:

//TrimApplication.HasUserInterface = false;
using (Database trimDb = new Database())
{
	trimDb.WorkgroupServerURL = _workgroupServerUrl;
	trimDb.Id = "00";
	trimDb.AuthenticationMethod = ClientAuthenticationMechanism.Adfs;
	trimDb.SetAuthenticationCredentials("domain\\myaccount", "password123!");
	trimDb.Connect();
	Console.WriteLine($"Connected: {trimDb.IsConnected}");
}
Console.ReadLine();

Despite trying to .SetAuthenticationCredentials it will prompt for ADFS credentials using the standard web-looking ADFS credentials form. If you enter the credentials in that displayed form, you're not prompted anymore, until the ADFS token expires, or you login and logout of Content Manager using your credentials. It doesn't use the supplied SetAuthenticationCredentials credentials at all it seems.

In fact, uncommenting that first line results in this error message when you try the Connect():

The authentication method 'Active Directory Federated Services' requires a user interface to gather credentials.

Is there any way at all for a .Net project to connect to an ADFS Workgroup Server by supplying credentials in code?

Matt

Labels (3)
0 Likes
1 Solution

Accepted Solutions
Micro Focus Expert
Micro Focus Expert

Re: .Net SDK using SetAuthenticationCredentials with ADFS

Jump to solution

CM 9.4 supports ADFS Confidential Clients, which allows you to authenticate without a UI.  Prior to 9.4 the only solution I can see is to bypass ADFS in some way, for example enable username/pwd (Explicit Windows) authentication on the WGS.


Blog | Samples | CM SDK Docs
**Any opinions expressed in this forum are my own personal opinion and should not be interpreted as an official statement on behalf of MicroFocus**

View solution in original post

3 Replies
Micro Focus Expert
Micro Focus Expert

Re: .Net SDK using SetAuthenticationCredentials with ADFS

Jump to solution

CM 9.4 supports ADFS Confidential Clients, which allows you to authenticate without a UI.  Prior to 9.4 the only solution I can see is to bypass ADFS in some way, for example enable username/pwd (Explicit Windows) authentication on the WGS.


Blog | Samples | CM SDK Docs
**Any opinions expressed in this forum are my own personal opinion and should not be interpreted as an official statement on behalf of MicroFocus**

View solution in original post

Matt Bayliss Honored Contributor.
Honored Contributor.

Re: .Net SDK using SetAuthenticationCredentials with ADFS

Jump to solution

Thanks David,

That's what I suspected - but that's really neat regarding CM9.4 and Confidential Clients - will have to have a play!

Cheers,

Matt.

0 Likes
Micro Focus Expert
Micro Focus Expert

Re: .Net SDK using SetAuthenticationCredentials with ADFS

Jump to solution

 

The code to connect using Confidential client looks like this.  I have not test this with AzureAD...

 

 

Database db = new Database();
db.AuthenticationMethod = ClientAuthenticationMechanism.Adfs;
string userName; // This should be the Replying Party Trust from ADFS.
string password; // This should be the Client Secret from ADFS.
db.SetAuthenticationCredentials(userName, password);
db.TrustedUser = "SomeUser"

 

 

 

        Database db = new Database();
        db.AuthenticationMethod = ClientAuthenticationMechanism.Adfs;
        string userName; // This should be the RPT from ADFS.
        string password; // This should be the Client Secret from ADFS.
        db.SetAuthenticationCredentials(userName, password);
        db.TrustedUser = "SomeUser"


Blog | Samples | CM SDK Docs
**Any opinions expressed in this forum are my own personal opinion and should not be interpreted as an official statement on behalf of MicroFocus**
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.