display properties of currently logged on user 
Author Message
 display properties of currently logged on user

Hello,

How can i get the properties of the current W2k AD user ?

thanks

Patrick



Tue, 21 Jun 2005 15:46:52 GMT  
 display properties of currently logged on user
There's some good stuff here that might help:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnw2...
html/passwords.asp it has all the properties of the ADSI user that you can
access and change. Here's some ADSI user functions that may be useful:

<%'***********************************************************
Sub PullAllDomains
    Dim objNameSpace
    Dim Domain

    Set objNameSpace = GetObject("WinNT:")
    For Each Domain in objNamespace
       Response.Write Domain.Name & "<br>"
    Next
  End sub

'***********************************************************
Sub PullAllComputers(strDomain)
    Dim PrimDomainContr, Computer

    Set PrimDomainContr = getobject("WinNT://" & strDomain)
    PrimDomainContr.filter = Array("Computer")

    For each Computer in PrimDomainContr
      Response.write Computer.Name  & "<br>"
    Next
  End sub

'***********************************************************
Sub DelComputerFromPDC(strDomain,strDelComputer)
    Dim PrimDomainContr
    Set PrimDomainContr = getobject("WinNT://" & strDomain)
    Call PrimDomainContr.Delete("Computer", strDelComputer)
  End Sub

'***********************************************************
sub PullAllUsers(strDomain)
    Dim Computer
    Dim User

    Set Computer = GetObject("WinNT://" & strDomain)
    Computer.Filter = Array("User")
    For Each User in Computer
      Response.Write User.Name  & "<br>"
    Next
  End Sub

'***********************************************************
Sub DispMinPassAge(strDomain)
    Dim Computer
    Set Computer = GetObject("WinNT://" & strDomain)
    Response.Write ((Computer.MinPasswordAge) / 86400)
  End Sub

'***********************************************************
Sub DispMinPassLength(strDomain)
    Dim Computer
    Set Computer= GetObject("WinNT://" & strDomain)
    Response.Write Computer.MinPasswordLength
  End Sub

'***********************************************************
Sub DispPassHisLength(strDomain)
    Dim Computer
    Set Computer = GetObject("WinNT://" & strDomain)
    Response.Write Computer.PasswordHistoryLength
  End Sub

'***********************************************************
Sub DispAutoUnlock(strDomain)
    Dim Computer
    Set Computer = GetObject("WinNT://" & strDomain)
    Response.Write Computer.AutoUnlockInterval
  End Sub
'***********************************************************
Sub PullAllGroups(strDomain)
    Dim Computer
    Dim Group

    Set Computer = GetObject("WinNT://" & strDomain)
    Computer.Filter = Array("Group")
    For Each Group in Computer
      Response.Write Group.Name  & "<br>"
    Next
  End Sub

'***********************************************************
Sub DispAutoUnlockObservation(strDomain)
    Dim Computer
    Set Computer = GetObject("WinNT://" & strDomain)
    Response.Write Computer.LockOutObservationInterval
  End Sub

'***********************************************************
Sub PullUserFullname(strDomain,strUser)
    Dim User
    'Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
    'Response.write User.Fullname
  End sub
'***********************************************************
Sub PullUserDescription(strDomain,strUser)
    Dim User
    Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
    Response.write User.Description
  End sub
'***********************************************************
  Sub PullUserMustChangePass(strDomain,strUser)
    Dim User
    Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
    Response.write User.Get("PasswordExpired")  '// 1 Means the Password
Expired
  End Sub

'***********************************************************
Sub PullUserCannotChangePass(strDomain,strUser)
    Dim User
    Dim Flags

    Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
    Flags = User.Get("UserFlags")
    Response.write  Flags And &H00040 '// 0 Means that user CAN change pass
  End sub
'***********************************************************
Sub PullPassNeverExpires(strDomain,strUser)
    Dim User
    Dim Flags

    Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
    Flags = User.Get("UserFlags")
    Response.write  Flags And &H10000 '// 0 Means that Password DOES expire
  End sub
'***********************************************************
Sub PullUserPassMinLength(strDomain,strUser)
    Dim User
    Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
    Response.Write User.PasswordMinimumLength
  End Sub

'***********************************************************
Sub PullUserPassRequired(strDomain,strUser)
    Dim User
    Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
    Response.Write User.PasswordRequired
  End Sub

'***********************************************************
Sub PullUserAccountDisabled(strDomain,strUser)
    Dim User
    Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
    Response.Write User.AccountDisabled
  End Sub
'***********************************************************
Sub PullUserAccountLockout(strDomain,strUser)
    Dim User
    Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
    Response.Write User.IsAccountLocked
  End Sub

'***********************************************************
Sub PullUserAccountType(strDomain,strUser)
    Dim User
    Dim Flags

    Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
    Flags = User.Get("UserFlags")
    Response.write  Flags And &H100  '// 0 Means that account is GLOBAL
  End sub

'***********************************************************
Sub PullUserProfilePath(strDomain,strUser)
    Dim User
    Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
    Response.Write User.Profile
  End Sub

'***********************************************************
Sub PullUserLoginScript(strDomain,strUser)
    Dim User
    Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
    Response.Write User.LoginScript
  End Sub

'***********************************************************
Sub PullUserHomeDirPath(strDomain,strUser)
    Dim User
    Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
    Response.Write User.HomeDirectory
  End Sub

'***********************************************************
Sub PullUserAccountExpireDate(strDomain,strUser)
    Dim User
    Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
    Response.Write User.AccountExpirationDate
  End Sub

'***********************************************************
Sub PullUserBadLoginCount(strDomain,strUser)
    Dim User
    Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
    Response.Write User.BadLoginCount
  End Sub

'***********************************************************
Sub PullUserLastLogin(strDomain,strUser)
    Dim User
    Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
    Response.Write User.LastLogin
  End Sub

'***********************************************************
 Sub PullUserLastLogoff(strDomain,strUser)
    Dim User
    Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
    Response.Write User.LastLogoff
  End Sub

'***********************************************************
Sub PullUserLastLogoff(strDomain,strUser)
    Dim User
    Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
    Response.Write User.LastLogoff
  End Sub

'***********************************************************
Sub PullUserLogonHourRestriction(strDomain,strUser)
    Dim User
    Dim RegTime
    Dim Restrict

    Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
    For Each RegTime In User.LoginHours
      If RegTime < 255 Then Restrict = True
    Next
    Response.write Restrict
  End Sub

'***********************************************************
 Sub PullAllUserFromGroup(strDomain,strGroup)
    Dim Group
    Dim User
    Set Group = GetObject("WinNT://" & strDomain & "/" & strGroup &
",group")
    For Each User in Group.Members
      Response.Write User.Name
    Next
  End Sub

'***********************************************************
 function DispUserInGroup(strDomain,strGroup,strUser)
    Dim Group
    Dim User
    Set Group = GetObject("WinNT://" & strDomain & "/" & strGroup &
",group")
    Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
    DispUserInGroup = Group.IsMember(User.ADsPath)
  End Function

'***********************************************************
Sub PullGroupDescription(strDomain,strGroup,strUser)
    Dim Group
    Set Group = GetObject("WinNT://" & strDomain & "/" & strGroup &
",group")
    Response.Write Group.Description
  End Sub

'***********************************************************
Sub DispUserInWhichGroup(strDomain,strGroup,strUser)
    Dim Group
    Dim User
    Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
    For Each Group in User.Groups
     Response.Write Group.Name
    Next
  End Sub

'***********************************************************
'***********************************************************%>

HTH,

Cheers,

Tim.



Tue, 21 Jun 2005 18:34:35 GMT  
 display properties of currently logged on user

Quote:

>Hello,

>How can i get the properties of the current W2k AD user ?

>thanks

>Patrick

Hi,

You can also use the ADSystemInfo object (on W2k clients)
to retrieve the full AdsPath of the current user. With
this, you can bind to the user object with the LDAP
provider, which exposes more attributes. For example:

Set oSysInfo = CreateObject("ADSystemInfo")
sUserAdsPath = oSysInfo.UserName
Set oUser = GetObject("LDAP://" & sUserAdsPath)
Wscript.Echo "User common name: " & oUser.cn
Wscript.Echo "User NT name: " & oUser.sAMAccountName
Wscript.Echo "User full name: " & oUser.DisplayName
Wscript.Echo "User first name: " & oUser.GivenName
Wscript.Echo "User last name: " & oUser.sn

' For a list of all attributes exposed by LDAP.

Set oClass = GetObject(oUser.Schema)

' Enumerate mandatory properties of the object.
For Each sProp In oClass.MandatoryProperties
  Wscript.Echo "(Mandatory) " & sProp
Next

' Enumerate optional properties of the object.
For Each sProp In oClass.OptionalProperties
  Wscript.Echo "(Optional) " & sProp
Next

Richard



Wed, 22 Jun 2005 15:01:52 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. currently logged on user

2. where are users currently logged in?

3. Get SID of currently logged on user

4. Find currently logged on Users

5. Get the name of currently logged on user

6. Currently logged on users

7. Assigning security permissions to the currently logged-on user

8. jsscript: getting userinfo of user currently logged on

9. Which Users are currently logged into a database?

10. Finding the ID of the user currently logged-in on a Win 95 desktop

11. Finding currently logged in user

12. Extract currently logged on user in SQL Server 6.5 from VB

 

 
Powered by phpBB® Forum Software