From 90317882414b7cbdf0a134a171a99b8214d9dda4 Mon Sep 17 00:00:00 2001
From: Nigel Kukard <nkukard@lbsd.net>
Date: Mon, 30 May 2016 09:02:23 +0000
Subject: [PATCH] Use login name if provided in LDAP

---
 awit-ssh | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/awit-ssh b/awit-ssh
index 4fb3527..fecc5ba 100755
--- a/awit-ssh
+++ b/awit-ssh
@@ -149,6 +149,7 @@ if ($mesg->code()) {
 
 # Some flags we may need
 my $needDSS;
+my $loginUsername;
 
 
 # If no matches
@@ -188,6 +189,12 @@ if ($ldapEntry) {
 		$port = $ldapLoginPort;
 	}
 
+	# Check if we need to set the username
+	if (my $ldapLoginUsername = $ldapEntry->get_value('awitLoginUsername')) {
+		logger('INFO',"  - Username %s (awitLoginUsername)",$ldapLoginUsername);
+		$loginUsername = $ldapLoginUsername;
+	}
+
 	# Check if we have a description
 	if (my $ldapDescription = $ldapEntry->get_value('description')) {
 		logger('INFO',"Description");
@@ -223,6 +230,11 @@ if (defined($port)) {
 	push(@sshArgs,'-p',$port);
 }
 
+# Check if we have a different username defined to login as
+if (defined($loginUsername)) {
+	push(@sshArgs,'-l',$loginUsername);
+}
+
 # If the server is ancient, we need to enable DSS
 if (defined($needDSS)) {
 	push(@sshArgs,'-o','PubkeyAcceptedKeyTypes=+ssh-dss');
-- 
GitLab