Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Error looping through publicDelegated

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,55954
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Error looping through publicDelegated
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Error looping through publicDelegated - 1/24/2008 10:40:56 PM   
  flederflick

 

Posts: 3
Score: 0
Joined: 1/24/2008
Status: offline
Hello everybody,
 
My first post   and i want to begin with a question.
 
I have the following code:
 
'On Error Resume Next
Dim OUUser
teller = 0
Set OUUser= GetObject("LDAP://OU=Users,DC=bla,DC=nl")
OUUser.Filter = Array("user")
For Each User In OUUser 
 GetUserAttribute(User.cn) 
Next
Sub GetUserAttribute(vUser)
 Dim MyVar
 Dim Delegates
 Set MyVar = GetObject ("LDAP://CN=" & vUser & ",OU=Users,DC=bla,DC=nl")
 DisplayName = MyVar.displayName 
 Delegates = MyVar.publicDelegates
 
 If Delegates <> Empty Then  
  WScript.Echo DisplayName & " Heeft de volgende Delegates" 
  For Each x In Delegates
     WScript.Echo vbTab & x
  Next
 Else
  WScript.Echo DisplayName & " ==> Heeft GEEN Delegates"
 End If 
End Sub
 
This is what i want to achieve:
 
Return all Users that have a mailbox connection to a selected user.
I loop through all users in the OU users and for all users I want to see which users had rights (delegates)  to the mailbox of that particular user.
 
When a user has no delegates return WScript.Echo DisplayName & " ==> Heeft GEEN Delegates"
Else loop through the users and return to the screen.
 
When a user has no delegates everything works fine but when a users does have one or more delegates the compiler begins to scream "Code: 800A000D The Data is invalid”
 
I have searched the internet but I can't find the solution.
 
 Can someone help me please?
 
Best Regards,
 
Sidney
 
 
 
 

_____________________________

==============================
No Sig Jet
==============================
 
 
Post #: 1
 
 RE: Error looping through publicDelegated - 1/25/2008 1:15:48 AM   
  ebgreen


Posts: 4971
Score: 31
Joined: 7/12/2005
Status: offline
Try changing this:

Delegates = MyVar.publicDelegates


to this:

Delegates = MyVar.GetEx("publicDelegates")

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to flederflick)
 
 
Post #: 2
 
 RE: Error looping through publicDelegated - 1/25/2008 1:31:17 AM   
  flederflick

 

Posts: 3
Score: 0
Joined: 1/24/2008
Status: offline
Problem found,
 
'On Error Resume Next
Dim OUUser
Set OUUser= GetObject("LDAP://OU=Users,DC=bla,DC=nl")
OUUser.Filter = Array("user")
For Each User In OUUser          
 GetUserAttribute(User.cn)          
Next
Sub GetUserAttribute(User)
  
 
    Dim MyVar
    Dim Delegates
    Set MyVar = GetObject ("LDAP://CN=" & User & ",OU=Users,DC=bla,DC=nl")
    DisplayName = MyVar.displayName       
 Delegates = MyVar.publicDelegates
 HandsAccount = MyVar.cn

 If IsEmpty(Delegates) Then       
  'WScript.Echo DisplayName & vbTab &" ==> Heeft GEEN Delegates"
    Else
  WScript.Echo DisplayName & "  (" & HandsAccount & ")" & vbTab &" || Heeft de volgende Delegates"  
  
  If (IsArray(Delegates) = True) Then  
   For Each x In Delegates
    WScript.Echo vbTab & GetNameByDisplayName(x)
   Next
  Else
    WScript.Echo vbTab & GetNameByDisplayName(Delegates)
  End If
  
 End If
End Sub
 
 
Function GetNameByDisplayName(vManagedBy)
 Dim ADUser
 Dim ReturnString
 Set ADUser = GetObject ("LDAP://" & vManagedBy)
 DisplayName = ADUser.displayName
 HandsCode = ADUser.cn
 ReturnString = DisplayName & "( " & HandsCOde & " )"
 GetNameByDisplayName =  ReturnString
End Function
 
 
 
 
There were 2 problems
 
1 The type of value of Delegates changes' when only 1 items is inserted. (Array and String)
2 I had to use the IsEmpty function to check if Delegates was filled
 
Thank everyone.
 
Sidney
 
 
 

_____________________________

==============================
No Sig Jet
==============================

(in reply to flederflick)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Error looping through publicDelegated Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts