Vault Login C# with Active Directory

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

Post Reply
ejhansen71
Posts: 61
Joined: Thu Nov 13, 2014 10:12 am
Location: Lake in the Hills, IL

Vault Login C# with Active Directory

Post by ejhansen71 » Mon Apr 13, 2015 10:47 am

I can create a login page using windows forms, but I need to be able to query our AD (active directory) for authentication.

I notice that on your Admin Web CLient, when adding a new user, you assign a Full NAme, Login id and email and there is an option to either use AD or not. We use it which makes everything so much easier.

How do I do that with my windows form program. The GUI I created (with A LOT of your help) works wonderfully, but currently we use a "master" user that has access to everything. Now that we have it working , we want to lock down the access. Can you point me to the correct Class and provide an example of how it should be implemented?

As always, Beth, you are the best!

Eric
Thanks!

Eric

Beth
Posts: 8550
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
Contact:

Re: Vault Login C# with Active Directory

Post by Beth » Mon Apr 13, 2015 4:04 pm

When a user in Vault is using AD authentication, the actual login is passed over to the domain, and it should send back a true or false.

You shouldn't have to write the actual piece that says whether to use AD or not. Create your user in Vault and use the exact AD login name. You don't need to put in the AD password.

You should also be able to look at a basic login with the CLC code that is included in the Vault API download.
Beth Kieler
SourceGear Technical Support

ejhansen71
Posts: 61
Joined: Thu Nov 13, 2014 10:12 am
Location: Lake in the Hills, IL

Re: Vault Login C# with Active Directory

Post by ejhansen71 » Tue Apr 14, 2015 4:48 pm

Beth - I don't want to use CLC - I am using C# and use a login method. I use the following constants:
c_url: our vault server
c_username: vlt
c_password: vltpassword

public static void Login() {
ServerOperations.client.LoginOptions.URL = c_url;
ServerOperations.client.LoginOptions.User = c_username;
ServerOperations.client.LoginOptions.Password = c_password;
ServerOperations.Login();
}

So now I want to use AD to validate login status. Your response makes it sound like I can simply pass the username without a password. However, that doesn't work. What setting do I need to use to make Vault work with only sending the username?
Thanks!

Eric

Beth
Posts: 8550
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
Contact:

Re: Vault Login C# with Active Directory

Post by Beth » Wed Apr 15, 2015 8:27 am

I mentioned the CLC because you can see how we wrote a login for it. The code that was used for writing it is included in the API download.

The decision to use AD or to not use it is on the Server side, not the client side. You wouldn't decide that in your code.

In the server, you make a user and set up that user to use AD authentication. This doesn't happen in client code.
Beth Kieler
SourceGear Technical Support

Beth
Posts: 8550
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
Contact:

Re: Vault Login C# with Active Directory

Post by Beth » Wed Apr 15, 2015 2:45 pm

When looking for the login in the CLC code, search for ServerOperations.Login();.
Beth Kieler
SourceGear Technical Support

Post Reply