1 17 package org.alfresco.filesys.smb.dcerpc.info; 18 19 import java.util.BitSet ; 20 21 import org.alfresco.filesys.smb.dcerpc.DCEBuffer; 22 import org.alfresco.filesys.smb.dcerpc.DCEBufferException; 23 import org.alfresco.filesys.smb.dcerpc.DCEReadable; 24 25 30 public class UserInfo implements DCEReadable 31 { 32 33 35 public static final int InfoLevel1 = 1; 36 public static final int InfoLevel3 = 3; 37 public static final int InfoLevel21 = 21; 38 39 55 57 public static final int PrivGuest = 0; 58 public static final int PrivUser = 1; 59 public static final int PrivAdmin = 2; 60 61 63 public static final int OperPrint = 0; 64 public static final int OperComm = 1; 65 public static final int OperServer = 2; 66 public static final int OperAccounts = 3; 67 68 70 private static final int AccountDisabled = 0x0001; 71 private static final int AccountHomeDirRequired = 0x0002; 72 private static final int AccountPasswordNotRequired = 0x0004; 73 private static final int AccountTemporaryDuplicate = 0x0008; 74 private static final int AccountNormal = 0x0010; 75 private static final int AccountMNSUser = 0x0020; 76 private static final int AccountDomainTrust = 0x0040; 77 private static final int AccountWorkstationTrust = 0x0080; 78 private static final int AccountServerTrust = 0x0100; 79 private static final int AccountPasswordNotExpire = 0x0200; 80 private static final int AccountAutoLocked = 0x0400; 81 82 84 private int m_infoLevel; 85 86 88 private String m_userName; 89 90 private int m_pwdAge; 91 private int m_priv; 92 93 private String m_homeDir; 94 private String m_comment; 95 private String m_description; 96 private String m_accComment; 97 98 private int m_flags; 99 100 private String m_scriptPath; 101 103 private String m_fullName; 104 private String m_appParam; 105 private String m_workStations; 106 107 private long m_lastLogon; 108 private long m_lastLogoff; 109 private long m_acctExpires; 110 private long m_lastPwdChange; 111 private long m_pwdCanChange; 112 private long m_pwdMustchange; 113 114 private int m_unitsPerWeek; 116 private byte[] m_logonHoursRaw; 117 private BitSet m_logonHours; 118 119 private int m_badPwdCount; 120 private int m_numLogons; 121 private String logonSrv; 122 123 private int m_countryCode; 124 private int m_codePage; 125 126 private int m_userRID; 127 private int m_groupRID; 128 130 private String m_profile; 131 private String m_homeDirDrive; 132 133 private int m_pwdExpired; 134 135 private String m_callBack; 136 private String m_unknown1; 137 private String m_unknown2; 138 private String m_unknown3; 139 140 143 public UserInfo() 144 { 145 } 146 147 152 public UserInfo(int lev) 153 { 154 m_infoLevel = lev; 155 } 156 157 162 public final int getInformationLevel() 163 { 164 return m_infoLevel; 165 } 166 167 172 public final String getLogonServer() 173 { 174 return logonSrv; 175 } 176 177 182 public final long getAccountExpires() 183 { 184 return m_acctExpires; 185 } 186 187 192 public final String getApplicationParameter() 193 { 194 return m_appParam; 195 } 196 197 202 public final int getBadPasswordCount() 203 { 204 return m_badPwdCount; 205 } 206 207 212 public final int getCodePage() 213 { 214 return m_codePage; 215 } 216 217 222 public final String getComment() 223 { 224 return m_comment; 225 } 226 227 232 public final String getDescription() 233 { 234 return m_description; 235 } 236 237 242 public final int getCountryCode() 243 { 244 return m_countryCode; 245 } 246 247 252 public final int getFlags() 253 { 254 return m_flags; 255 } 256 257 262 public final boolean isDisabled() 263 { 264 return (m_flags & AccountDisabled) != 0 ? true : false; 265 } 266 267 272 public final boolean requiresHomeDirectory() 273 { 274 return (m_flags & AccountHomeDirRequired) != 0 ? true : false; 275 } 276 277 282 public final boolean requiresPassword() 283 { 284 return (m_flags & AccountPasswordNotRequired) != 0 ? false : true; 285 } 286 287 292 public final boolean isNormalUser() 293 { 294 return (m_flags & AccountNormal) != 0 ? true : false; 295 } 296 297 302 public final boolean isDomainTrust() 303 { 304 return (m_flags & AccountDomainTrust) != 0 ? true : false; 305 } 306 307 312 public final boolean isWorkstationTrust() 313 { 314 return (m_flags & AccountWorkstationTrust) != 0 ? true : false; 315 } 316 317 322 public final boolean isServerTrust() 323 { 324 return (m_flags & AccountServerTrust) != 0 ? true : false; 325 } 326 327 332 public final boolean passwordExpires() 333 { 334 return (m_flags & AccountPasswordNotExpire) != 0 ? false : true; 335 } 336 337 342 public final boolean isAutoLocked() 343 { 344 return (m_flags & AccountAutoLocked) != 0 ? true : false; 345 } 346 347 352 public final String getFullName() 353 { 354 return m_fullName; 355 } 356 357 362 public final int getGroupRID() 363 { 364 return m_groupRID; 365 } 366 367 372 public final String getHomeDirectory() 373 { 374 return m_homeDir; 375 } 376 377 382 public final String getHomeDirectoryDrive() 383 { 384 return m_homeDirDrive; 385 } 386 387 392 public final long getLastLogoff() 393 { 394 return m_lastLogoff; 395 } 396 397 402 public final long getLastLogon() 403 { 404 return m_lastLogon; 405 } 406 407 412 public final BitSet getLogonHours() 413 { 414 return m_logonHours; 415 } 416 417 422 public final int numberOfLogons() 423 { 424 return m_numLogons; 425 } 426 427 432 public final int getPrivileges() 433 { 434 return m_priv; 435 } 436 437 442 public final String getProfile() 443 { 444 return m_profile; 445 } 446 447 452 public final int getPasswordExpired() 453 { 454 return m_pwdExpired; 455 } 456 457 462 public final String getLogonScriptPath() 463 { 464 return m_scriptPath; 465 } 466 467 472 public final int getUnitsPerWeek() 473 { 474 return m_unitsPerWeek; 475 } 476 477 482 public final String getUserName() 483 { 484 return m_userName; 485 } 486 487 492 public final int getUserRID() 493 { 494 return m_userRID; 495 } 496 497 502 public final String getWorkStations() 503 { 504 return m_workStations; 505 } 506 507 512 public final long getLastPasswordChange() 513 { 514 return m_lastPwdChange; 515 } 516 517 522 public final long getPasswordMustChangeBy() 523 { 524 return m_pwdMustchange; 525 } 526 527 530 private final void clearStrings() 531 { 532 533 535 m_appParam = null; 536 m_comment = null; 537 m_fullName = null; 538 m_homeDir = null; 539 m_homeDirDrive = null; 540 m_profile = null; 541 m_scriptPath = null; 542 m_userName = null; 543 m_workStations = null; 544 m_description = null; 545 m_accComment = null; 546 } 547 548 554 public void readObject(DCEBuffer buf) throws DCEBufferException 555 { 556 557 559 clearStrings(); 560 561 563 int ival = 0; 564 int pval = 0; 565 566 switch (getInformationLevel()) 567 { 568 569 571 case InfoLevel1: 572 m_userName = buf.getCharArrayPointer(); 573 m_fullName = buf.getCharArrayPointer(); 574 m_groupRID = buf.getInt(); 575 m_description = buf.getCharArrayPointer(); 576 m_comment = buf.getCharArrayPointer(); 577 break; 578 579 581 case InfoLevel3: 582 m_userName = buf.getCharArrayPointer(); 583 m_fullName = buf.getCharArrayPointer(); 584 585 m_userRID = buf.getInt(); 586 m_groupRID = buf.getInt(); 587 588 m_homeDir = buf.getCharArrayPointer(); 589 m_homeDirDrive = buf.getCharArrayPointer(); 590 m_scriptPath = buf.getCharArrayPointer(); 591 m_profile = buf.getCharArrayPointer(); 592 m_workStations = buf.getCharArrayPointer(); 593 594 m_lastLogon = buf.getNTTime(); 595 m_lastLogoff = buf.getNTTime(); 596 m_lastPwdChange = buf.getNTTime(); 597 buf.skipBytes(8); buf.skipBytes(8); 600 ival = buf.getShort(DCEBuffer.ALIGN_INT); 601 pval = buf.getPointer(); 602 603 if (ival != 0 && pval != 0) 604 m_logonHoursRaw = new byte[ival / 8]; 605 606 m_badPwdCount = buf.getShort(); 607 m_numLogons = buf.getShort(); 608 609 m_flags = buf.getInt(); 610 break; 611 612 614 case InfoLevel21: 615 m_lastLogon = buf.getNTTime(); 616 m_lastLogoff = buf.getNTTime(); 617 m_lastPwdChange = buf.getNTTime(); 618 m_acctExpires = buf.getNTTime(); 619 m_pwdCanChange = buf.getNTTime(); 620 m_pwdMustchange = buf.getNTTime(); 621 622 m_userName = buf.getCharArrayPointer(); 623 m_fullName = buf.getCharArrayPointer(); 624 625 m_homeDir = buf.getCharArrayPointer(); 626 m_homeDirDrive = buf.getCharArrayPointer(); 627 m_scriptPath = buf.getCharArrayPointer(); 628 m_profile = buf.getCharArrayPointer(); 629 m_description = buf.getCharArrayPointer(); 630 m_workStations = buf.getCharArrayPointer(); 631 m_accComment = buf.getCharArrayPointer(); 632 633 m_callBack = buf.getCharArrayPointer(); 634 m_unknown1 = buf.getCharArrayPointer(); 635 m_unknown2 = buf.getCharArrayPointer(); 636 m_unknown3 = buf.getCharArrayPointer(); 637 638 buf.skipBytes(8); 640 m_userRID = buf.getInt(); 641 m_groupRID = buf.getInt(); 642 643 m_flags = buf.getInt(); 644 645 buf.getInt(); 647 ival = buf.getShort(DCEBuffer.ALIGN_INT); 648 pval = buf.getPointer(); 649 650 if (ival != 0 && pval != 0) 651 m_logonHoursRaw = new byte[ival / 8]; 652 653 m_badPwdCount = buf.getShort(); 654 m_numLogons = buf.getShort(); 655 656 m_countryCode = buf.getShort(); 657 m_codePage = buf.getShort(); 658 659 buf.skipBytes(2); 661 m_pwdExpired = buf.getByte(DCEBuffer.ALIGN_INT); 662 break; 663 } 664 } 665 666 672 public void readStrings(DCEBuffer buf) throws DCEBufferException 673 { 674 675 677 switch (getInformationLevel()) 678 { 679 680 682 case InfoLevel1: 683 m_userName = buf.getCharArrayNotNull(m_userName, DCEBuffer.ALIGN_INT); 684 m_fullName = buf.getCharArrayNotNull(m_fullName, DCEBuffer.ALIGN_INT); 685 686 m_description = buf.getCharArrayNotNull(m_description, DCEBuffer.ALIGN_INT); 687 m_comment = buf.getCharArrayNotNull(m_comment, DCEBuffer.ALIGN_INT); 688 break; 689 690 692 case InfoLevel3: 693 m_userName = buf.getCharArrayNotNull(m_userName, DCEBuffer.ALIGN_INT); 694 m_fullName = buf.getCharArrayNotNull(m_fullName, DCEBuffer.ALIGN_INT); 695 696 m_homeDir = buf.getCharArrayNotNull(m_homeDir, DCEBuffer.ALIGN_INT); 697 m_homeDirDrive = buf.getCharArrayNotNull(m_homeDirDrive, DCEBuffer.ALIGN_INT); 698 699 m_scriptPath = buf.getCharArrayNotNull(m_scriptPath, DCEBuffer.ALIGN_INT); 700 m_profile = buf.getCharArrayNotNull(m_profile, DCEBuffer.ALIGN_INT); 701 m_workStations = buf.getCharArrayNotNull(m_workStations, DCEBuffer.ALIGN_INT); 702 703 m_logonHoursRaw = buf.getByteStructure(m_logonHoursRaw); 704 break; 705 706 708 case InfoLevel21: 709 m_userName = buf.getCharArrayNotNull(m_userName, DCEBuffer.ALIGN_INT); 710 m_fullName = buf.getCharArrayNotNull(m_fullName, DCEBuffer.ALIGN_INT); 711 712 m_homeDir = buf.getCharArrayNotNull(m_homeDir, DCEBuffer.ALIGN_INT); 713 m_homeDirDrive = buf.getCharArrayNotNull(m_homeDirDrive, DCEBuffer.ALIGN_INT); 714 715 m_scriptPath = buf.getCharArrayNotNull(m_scriptPath, DCEBuffer.ALIGN_INT); 716 m_profile = buf.getCharArrayNotNull(m_profile, DCEBuffer.ALIGN_INT); 717 m_description = buf.getCharArrayNotNull(m_description, DCEBuffer.ALIGN_INT); 718 m_workStations = buf.getCharArrayNotNull(m_workStations, DCEBuffer.ALIGN_INT); 719 m_accComment = buf.getCharArrayNotNull(m_profile, DCEBuffer.ALIGN_INT); 720 721 m_callBack = buf.getCharArrayNotNull(m_callBack, DCEBuffer.ALIGN_INT); 722 m_unknown1 = buf.getCharArrayNotNull(m_unknown1, DCEBuffer.ALIGN_INT); 723 m_unknown2 = buf.getCharArrayNotNull(m_unknown2, DCEBuffer.ALIGN_INT); 724 m_unknown3 = buf.getCharArrayNotNull(m_unknown3, DCEBuffer.ALIGN_INT); 725 726 m_logonHoursRaw = buf.getByteStructure(m_logonHoursRaw); 727 break; 728 } 729 } 730 731 737 public final static String getAccountTypeAsString(int typ) 738 { 739 String ret = ""; 740 switch (typ) 741 { 742 case PrivGuest: 743 ret = "Guest"; 744 break; 745 case PrivUser: 746 ret = "User"; 747 break; 748 case PrivAdmin: 749 ret = "Administrator"; 750 break; 751 } 752 return ret; 753 } 754 755 760 public String toString() 761 { 762 StringBuffer str = new StringBuffer (); 763 764 str.append("["); 765 str.append(getUserName()); 766 str.append(":"); 767 str.append(getInformationLevel()); 768 str.append(":"); 769 770 str.append("]"); 771 return str.toString(); 772 } 773 } | Popular Tags |