@@ -25,27 +25,35 @@ func parseUser(un string, opts ...Option) userCred {
2525// the domain name, user name, and workstation.
2626func parseDomainUserWorkstation (un string , opts ... Option ) (string , string , string ) {
2727
28- wkst := ""
28+ wkst , dn := "" , ""
2929
3030 for _ , opt := range opts {
3131 switch v := opt .(type ) {
3232 case wkstOpt :
3333 wkst = string (v )
34+ case domainOpt :
35+ dn = string (v )
3436 }
3537 }
3638
3739 // down-level logon name.
3840 if strings .Contains (un , "\\ " ) {
3941 un := strings .SplitN (un , "\\ " , 2 )
42+ if dn != "" {
43+ return dn , un [1 ], wkst
44+ }
4045 return un [0 ], un [1 ], wkst
4146 }
4247
4348 if strings .Contains (un , "@" ) {
4449 un := strings .SplitN (un , "@" , 2 )
50+ if dn != "" {
51+ return dn , un [0 ], wkst
52+ }
4553 return un [1 ], un [0 ], wkst
4654 }
4755
48- return "" , un , wkst
56+ return dn , un , wkst
4957}
5058
5159// DomainName function returns the domain name from the user name.
@@ -66,3 +74,18 @@ func NewFromString(s string, opts ...Option) Password {
6674 }
6775 return NewFromPassword (s , "" , append (opts , AllowEmptyPassword ())... )
6876}
77+
78+ func V8ToV9 (cred Credential ) Credential {
79+
80+ if cred , ok := (any )(cred ).(KeytabV8 ); ok {
81+ return NewFromKeytabV8 (cred .UserName (), cred .Keytab (),
82+ Workstation (cred .Workstation ()), Domain (cred .DomainName ()))
83+ }
84+
85+ if cred , ok := (any )(cred ).(CCacheV8 ); ok {
86+ return NewFromCCacheV8 (cred .UserName (), cred .CCache (),
87+ Workstation (cred .Workstation ()), Domain (cred .DomainName ()))
88+ }
89+
90+ return cred
91+ }
0 commit comments