Difference between revisions of "Microsoft KB Archive/251174"

From BetaArchive Wiki
m (Text replacement - ">" to ">")
m (Text replacement - """ to """)
 
Line 61: Line 61:
 
       strUserDn, strDistListDn, strAdmin, strAdminPwd
 
       strUserDn, strDistListDn, strAdmin, strAdminPwd
  
   strLdapSrv      = "LDAP://localhost:5292"
+
   strLdapSrv      = "LDAP://localhost:5292"
   strRoot          = "o=Microsoft"
+
   strRoot          = "o=Microsoft"
   strMemberPath    = ",ou=Members," + strRoot
+
   strMemberPath    = ",ou=Members," + strRoot
   strUserCn        = "cn=JohnDoe"
+
   strUserCn        = "cn=JohnDoe"
 
   strUserDn        = strUserCn + strMemberPath
 
   strUserDn        = strUserCn + strMemberPath
   strDistListDn    = strLdapSrv + &quot;/&quot; + strRoot + _<BR/>
+
   strDistListDn    = strLdapSrv + "/" + strRoot + _<BR/>
     &quot;/ou=DistributionLists/cn=KmBriefList&quot;
+
     "/ou=DistributionLists/cn=KmBriefList"
   strAdmin        = &quot;cn=Administrator,ou=Members,&quot; + strRoot
+
   strAdmin        = "cn=Administrator,ou=Members," + strRoot
   strAdminPwd      = &quot;password&quot;
+
   strAdminPwd      = "password"
  
 
   'Bind to the specific Distribution List using Administrator credentials
 
   'Bind to the specific Distribution List using Administrator credentials
   Set adsDistList = GetObject(&quot;LDAP:&quot;)
+
   Set adsDistList = GetObject("LDAP:")
 
   Set adsDistList = adsDistList.OpenDSObject(strDistListDn, strAdmin, _
 
   Set adsDistList = adsDistList.OpenDSObject(strDistListDn, strAdmin, _
 
                                     strAdminPwd, CLng(0))
 
                                     strAdminPwd, CLng(0))
  
 
   ' Append the new member to the ones in the distribution list
 
   ' Append the new member to the ones in the distribution list
   adsDistList.PutEx ADS_ATTR_APPEND, &quot;dlMember&quot;, Array(strUserDN)
+
   adsDistList.PutEx ADS_ATTR_APPEND, "dlMember", Array(strUserDN)
  
 
   'Flush the property cache and update the directory
 
   'Flush the property cache and update the directory

Latest revision as of 13:51, 21 July 2020

Knowledge Base


How to Programmatically Add Members to Distribution Lists

Article ID: 251174

Article Last Modified on 2/4/2000



APPLIES TO

  • Microsoft Site Server 3.0 Standard Edition



This article was previously published under Q251174

SUMMARY

This article describes how to programmatically add a member to a specific distribution list in a Site Server 3.0 Membership directory using Active Directory Service Interfaces (ADSI) 2.5 and VBScript.

MORE INFORMATION

To add a member to a distribution list in Site Server 3.0, perform the following steps:

  1. Bind to the Distribution List in which you want to add the user.
  2. Append the Distinguished Name (DN) of the user who you want to add to the Distribution List.

The following code illustrates this procedure:

   Const ADS_ATTR_APPEND = 3

   Dim strDistList, strLdapSrv, strRoot, strMemberPath, strUserCn, _ <BR/>
      strUserDn, strDistListDn, strAdmin, strAdminPwd

   strLdapSrv       = "LDAP://localhost:5292"
   strRoot          = "o=Microsoft"
   strMemberPath    = ",ou=Members," + strRoot
   strUserCn        = "cn=JohnDoe"
   strUserDn        = strUserCn + strMemberPath
   strDistListDn    = strLdapSrv + "/" + strRoot + _<BR/>
     "/ou=DistributionLists/cn=KmBriefList"
   strAdmin         = "cn=Administrator,ou=Members," + strRoot
   strAdminPwd      = "password"

   'Bind to the specific Distribution List using Administrator credentials
   Set adsDistList = GetObject("LDAP:")
   Set adsDistList = adsDistList.OpenDSObject(strDistListDn, strAdmin, _
                                    strAdminPwd, CLng(0))

   ' Append the new member to the ones in the distribution list
   adsDistList.PutEx ADS_ATTR_APPEND, "dlMember", Array(strUserDN)

   'Flush the property cache and update the directory
    adsDistList.SetInfo

   'Destroy the objects
    Set adsDistList  = Nothing
                

REFERENCES

251176 How to Programmatically Remove Members from Distribution ListsFor information on Active Directory Service Interfaces version 2.5, go to the following directory in the MSDN Online Library:

SDK Documentation / Platform SDK / Networking and Directory Services / Active Directory, ADSI, and Directory Services / Active Directory Service Interfaces


Keywords: kbhowto kbinfo KB251174