2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 #include <afs/param.h>
15 #include "TaAfsUsrMgr.h"
20 * USER-VIEW COLUMNS __________________________________________________________
24 void User_SetDefaultView (LPVIEWINFO lpvi, ICONVIEW *piv)
26 lpvi->lvsView = FLS_VIEW_SMALL;
27 lpvi->nColsAvail = nUSERCOLUMNS;
29 for (size_t iCol = 0; iCol < nUSERCOLUMNS; ++iCol)
31 lpvi->cxColumns[ iCol ] = USERCOLUMNS[ iCol ].cxWidth;
32 lpvi->idsColumns[ iCol ] = USERCOLUMNS[ iCol ].idsColumn;
35 lpvi->iSort = usrcolNAME;
38 lpvi->aColumns[0] = (int)usrcolNAME;
39 lpvi->aColumns[1] = (int)usrcolUID;
40 lpvi->aColumns[2] = (int)usrcolCHANGEPW;
41 lpvi->aColumns[3] = (int)usrcolREUSEPW;
42 lpvi->aColumns[4] = (int)usrcolEXPIRES;
48 void User_GetColumn (ASID idObject, USERCOLUMN iCol, LPTSTR pszText, LPSYSTEMTIME pstDate, LONG *pcsec, COLUMNTYPE *pcType)
51 *pszText = TEXT('\0');
53 memset (pstDate, 0x00, sizeof(SYSTEMTIME));
57 *pcType = ctALPHABETIC;
60 if (asc_ObjectPropertiesGet_Fast (g.idClient, g.idCell, idObject, &Properties))
66 *pcType = ctALPHABETIC;
68 User_GetDisplayName (pszText, &Properties);
73 *pcType = ctALPHABETIC;
76 if (Properties.u.UserProperties.fHaveKasInfo)
78 if (Properties.u.UserProperties.KASINFO.fIsAdmin)
80 GetString (pszText, IDS_USRFLAG_ADMIN);
81 pszText = &pszText[ lstrlen(pszText) -1 ];
83 if (Properties.u.UserProperties.KASINFO.fCanGetTickets)
85 GetString (pszText, IDS_USRFLAG_TICKET);
86 pszText = &pszText[ lstrlen(pszText) -1 ];
88 if (Properties.u.UserProperties.KASINFO.fEncrypt)
90 GetString (pszText, IDS_USRFLAG_ENCRYPT);
91 pszText = &pszText[ lstrlen(pszText) -1 ];
93 if (Properties.u.UserProperties.KASINFO.fCanChangePassword)
95 GetString (pszText, IDS_USRFLAG_CHANGEPW);
96 pszText = &pszText[ lstrlen(pszText) -1 ];
98 if (Properties.u.UserProperties.KASINFO.fCanReusePasswords)
100 GetString (pszText, IDS_USRFLAG_REUSEPW);
101 pszText = &pszText[ lstrlen(pszText) -1 ];
109 *pcType = ctALPHABETIC;
110 if (Properties.u.UserProperties.fHaveKasInfo)
113 GetString (pszText, (Properties.u.UserProperties.KASINFO.fIsAdmin) ? IDS_YES : IDS_NO);
119 *pcType = ctALPHABETIC;
120 if (Properties.u.UserProperties.fHaveKasInfo)
123 GetString (pszText, (Properties.u.UserProperties.KASINFO.fCanGetTickets) ? IDS_YES : IDS_NO);
129 *pcType = ctALPHABETIC;
130 if (Properties.u.UserProperties.fHaveKasInfo)
133 GetString (pszText, (Properties.u.UserProperties.KASINFO.fEncrypt) ? IDS_NO : IDS_YES);
139 *pcType = ctALPHABETIC;
140 if (Properties.u.UserProperties.fHaveKasInfo)
143 GetString (pszText, (Properties.u.UserProperties.KASINFO.fCanChangePassword) ? IDS_YES : IDS_NO);
149 *pcType = ctALPHABETIC;
150 if (Properties.u.UserProperties.fHaveKasInfo)
153 GetString (pszText, (Properties.u.UserProperties.KASINFO.fCanReusePasswords) ? IDS_YES : IDS_NO);
160 if (Properties.u.UserProperties.fHaveKasInfo)
163 FormatTime (pszText, TEXT("%t"), &Properties.u.UserProperties.KASINFO.timeExpires);
165 memcpy (pstDate, &Properties.u.UserProperties.KASINFO.timeExpires, sizeof(SYSTEMTIME));
172 if (Properties.u.UserProperties.fHaveKasInfo)
175 FormatTime (pszText, TEXT("%t"), &Properties.u.UserProperties.KASINFO.timeLastPwChange);
177 memcpy (pstDate, &Properties.u.UserProperties.KASINFO.timeLastPwChange, sizeof(SYSTEMTIME));
184 if (Properties.u.UserProperties.fHaveKasInfo)
187 FormatTime (pszText, TEXT("%t"), &Properties.u.UserProperties.KASINFO.timeLastMod);
189 memcpy (pstDate, &Properties.u.UserProperties.KASINFO.timeLastMod, sizeof(SYSTEMTIME));
193 case usrcolLASTMODBY:
195 *pcType = ctALPHABETIC;
196 if (Properties.u.UserProperties.fHaveKasInfo)
199 lstrcpy (pszText, Properties.u.UserProperties.KASINFO.szUserLastMod);
206 if (Properties.u.UserProperties.fHaveKasInfo)
209 FormatElapsedSeconds (pszText, Properties.u.UserProperties.KASINFO.csecTicketLifetime);
211 *pcsec = Properties.u.UserProperties.KASINFO.csecTicketLifetime;
218 if (Properties.u.UserProperties.fHaveKasInfo)
221 FormatElapsedSeconds (pszText, Properties.u.UserProperties.KASINFO.cdayPwExpire * csec1DAY);
223 *pcsec = Properties.u.UserProperties.KASINFO.cdayPwExpire * csec1DAY;
227 case usrcolCFAILLOGIN:
230 if (Properties.u.UserProperties.fHaveKasInfo)
233 wsprintf (pszText, TEXT("%lu"), Properties.u.UserProperties.KASINFO.cFailLogin);
240 if (Properties.u.UserProperties.fHaveKasInfo)
243 FormatElapsedSeconds (pszText, Properties.u.UserProperties.KASINFO.csecFailLoginLock);
245 *pcsec = Properties.u.UserProperties.KASINFO.csecFailLoginLock;
249 case usrcolCGROUPMAX:
252 if (Properties.u.UserProperties.fHavePtsInfo)
255 wsprintf (pszText, TEXT("%lu"), Properties.u.UserProperties.PTSINFO.cgroupCreationQuota);
262 if (Properties.u.UserProperties.fHavePtsInfo)
265 wsprintf (pszText, TEXT("%ld"), Properties.u.UserProperties.PTSINFO.uidName);
271 *pcType = ctALPHABETIC;
272 if (Properties.u.UserProperties.fHavePtsInfo)
276 if (Properties.u.UserProperties.PTSINFO.szOwner[0])
277 wsprintf (pszText, TEXT("%s (%ld)"), Properties.u.UserProperties.PTSINFO.szOwner, Properties.u.UserProperties.PTSINFO.uidOwner);
279 wsprintf (pszText, TEXT("%ld"), Properties.u.UserProperties.PTSINFO.uidOwner);
286 *pcType = ctALPHABETIC;
287 if (Properties.u.UserProperties.fHavePtsInfo)
291 if (Properties.u.UserProperties.PTSINFO.szCreator[0])
292 wsprintf (pszText, TEXT("%s (%ld)"), Properties.u.UserProperties.PTSINFO.szCreator, Properties.u.UserProperties.PTSINFO.uidCreator);
294 wsprintf (pszText, TEXT("%ld"), Properties.u.UserProperties.PTSINFO.uidCreator);
303 BOOL User_GetDisplayName (LPTSTR pszText, LPASOBJPROP pProperties)
305 lstrcpy (pszText, pProperties->szName);
307 if (pProperties->u.UserProperties.szInstance[0])
309 // Don't show the Instance value for certain entries
310 if ( (lstrcmpi (pProperties->szName, TEXT("admin"))) &&
311 (lstrcmpi (pProperties->szName, TEXT("krbtgt"))) )
313 wsprintf (&pszText[ lstrlen(pszText) ], TEXT(".%s"), pProperties->u.UserProperties.szInstance);
321 BOOL User_GetDisplayName (LPTSTR pszText, ASID idUser)
323 ASOBJPROP Properties;
324 if (asc_ObjectPropertiesGet_Fast (g.idClient, g.idCell, idUser, &Properties))
326 return User_GetDisplayName (pszText, &Properties);
330 return asc_ObjectNameGet_Fast (g.idClient, g.idCell, idUser, pszText);
335 void User_SplitDisplayName (LPTSTR pszFull, LPTSTR pszName, LPTSTR pszInstance)
338 lstrcpy (pszName, pszFull);
340 lstrcpy (pszInstance, TEXT(""));
342 if (!fIsMachineAccount (pszFull))
344 if (pszName && pszInstance)
347 if ((pchDot = (LPTSTR)lstrchr (pszName, TEXT('.'))) != NULL)
349 *pchDot = TEXT('\0');
350 lstrcpy (pszInstance, &pchDot[1]);